Pular para o conteúdo principal

API authentication and errors

Every call to the Amplia Reg API uses the same endpoint, the same API key and the same error response format.

Endpoint​

All API URLs are relative to the endpoint. The endpoint is the address of the Amplia Reg instance. It is the same as the address of the control panel, for example https://ampliareg.yourcompany.com. If you do not know the address, ask the administrator of your Amplia Reg instance.

API key​

Every call requires an API key, in the X-Api-Key header:

X-Api-Key: your-app|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Or in the Authorization header, with the ApiKey scheme:

Authorization: ApiKey your-app|xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

The key has the format application-name|<key> and works only on the instance where you created it. To create a key, see Get started.

Application roles​

The key belongs to an application, and the application's roles define what the key can do:

RoleOperations
Sales appCreating and canceling orders, holder checks, sending holder documents and listing the status changes
Electronic registration authorityCreating pre-approved orders, getting the issue keys and issue links, resending the issue instructions and listing the status changes

The Sales app role cannot get the order (GET /api/brazil/orders/{number} and the routes of the other formats). It also cannot create orders with startValidation. For these calls, the API responds with HTTP 403. To follow the order, use the webhooks or the status change list.

The phone number validation accepts any API key.

Application subscription​

Each application belongs to a subscription: a certification authority (CA) or a registration authority (RA). The calls of the application apply to that subscription. For example, the certificate type list has the types of the CA of the application.

Some APIs require the RA in the X-Subscription header, for example the pre-approved orders API. When a subscription is missing, the API responds with the SubscriptionRequired error code.

HTTP status codes​

CodeMeaning
200 (OK)The request was processed. The response body depends on the API: see the API reference
400 (Bad Request)A required field is missing or has an incorrect value. This also applies to the fields that are required only in some cases, for example contact for the VideoIdentification and OnlineIssuance issue types
401 (Unauthorized)The API key was not sent or is invalid
403 (Forbidden)The API key is valid, but the application does not have the role the operation requires
415 (Unsupported Media Type)The request body is empty or is not JSON
422 (Unprocessable Entity)API error: a business rule stopped the operation, for example an order that was not found. The body is an ErrorModel
500 (Internal Server Error)An unexpected error happened. The exceptionCode field of the body helps with the diagnosis

ErrorModel​

FieldTypeContent
codestringThe error code. Test this field in your code, not the message. See the error codes
messagestringA description of the error, in English. Log it, but do not show it to the user
{
"code": "OrderNotFound",
"message": "Order not found: 100123456"
}

Language​

The API reads the Accept-Language header. The header accepts these values:

  • pt-BR (or pt)
  • en-US (or en)
  • es-ES (or es)

Error messages do not change with this header.

See also​

View as Markdown