Ir para o conteúdo

Stored Data API

The Stored Data API is used to work with the data stored in the system. Queries to this API allow to get information about:

  • Operators
  • Chats
  • Categories
  • Tariffs
  • Departments
  • Statistics

Also Stored Data API provides an opportunity to order services.

Base URL

The base URL is the domain of your account, and it depends on your network configuration. It looks like:

https://{hostname}/api/v{api_version}/{path}

Where {hostname} is the host name where the Rox.Chat Server is located, in the format {account}.rox.chat for cloud clients and chat.mycompany.com for hosted clients. {path} represents the API command.

You send requests to the base URL to access the Rox.Chat Stored Data API.

Example of a ready request to Rox.Chat Stored Data API:

https://company.rox.chat/api/v4/operators

This request should return a list of all agents.

To access the Rox.Chat Stored Data API, you need to authenticate.

Authorization, API Access

To gain access to the Rox.Chat Stored Data API, you need to contact the technical support of the Rox.Chat service. Access uses the administrator's email and password (admin_password). Basic authorization is done as follows:

curl -u adm@domain.com:password {base_url}/api/v{api_version}/{request}

Where base_url is the base URL for your network configuration, and request is your API query.

Thus, after curl -u, you have the user's email, followed by a colon, their password, and then the request URL.

The API operates exclusively over the HTTPS protocol. All data returns in the UTF-8 encoding. The time format is ISO 8601 with UTC as the time zone. The format for time intervals is in seconds.

Error Handling

If an incorrect password is entered or the user doesn't exist, the HTTP code 401 is returned.

If the agent isn't an administrator or too many authorization attempts have been made, the HTTP code 403 is returned. Other errors come in the following JSON format (with HTTP code 200 unless otherwise specified):

{"error":"error-code"}

Possible error types:

Error Code Description
chat-not-found Chat not found
wrong-date-format Wrong date format
wrong-price Wrong price
wrong-period Wrong time period
no-tariff-option The account does not have access to the API
no-partner-option The account is not an affiliate account
account-blocked Account blocked
db-schema-archived The database is archived
auth-attempts-limit-reached The limit of authorization attempts has been exhausted
unauthorized User not authorized
unknown-method Incorrect type of request is set
unknown-mode Incorrect query mode is selected
argument-missing There are not enough arguments for the query
internal problem Internal service error
unknown Unknown error