API
Endpointsβ
The API is accessible at the following endpoint: https://api.breign.eu.
For sensitive use-cases, you may want to contact your support representative for a custom on-premise deployment of the Breign platform.
Authenticationβ
To request the Breign API, you need an API Key or an access token for your account. You can generate a new API Key on the Breign web app under your profile.
All request are authenticated by adding a x-api-key header with the account's API Key. The API Key grants access to all ressources (agents, applications, organizations...) accessible to the user it was generated for.
API auth flowβ
You can also generate a new API or a token Key by performing the following request:
POST {{endpoint}}/auth/code
Body :
{
"email": "your.email@example.com",
"type": "api_key" or "jwt"
}
Response :
{
"id": "cff0505b-a78c-4723-baf0-42ebcc2f72f0"
}
A unique code is sent to the mailbox if the account exists. Verify the code with the following request (using the id returned in the previous request):
POST {{endpoint}}/auth/code/:codeId/verifications
Body :
{
"code": "09HD74KM"
}
Response :
{
"secret": "ai-98747777HDHAHZFJzad8746D"
}
or
{
"token": "ey...."
}
Tokens expire in 1 hour after their generation. API keys does not expire but can be removed from your account in your settings.
Application credentialsβ
An application (an avatar, a remote, your own client) can call some routes without a user account:
- with its appId:appSecret pair, sent as the API key:
x-api-key: <appId>:<appSecret>; - with the token of an ephemeral instance, sent as
Authorization: Bearer <token>.
These credentials are accepted by:
| Route | appId:appSecret pair | Instance token |
|---|---|---|
GET /conversations/:conversationId | Conversations of the application | Conversations of that instance only |
GET /conversations/:conversationId/messages/:messageId | Conversations of the application | Conversations of that instance only |
POST /apps/:appId/instances/:instanceId/token | Yes | No (403) |
POST /apps/:appId/instances/:instanceId/token issues a new token for an ephemeral instance and revokes the previous one. The response carries the instance with its new token and expiresAt. An active instance is simply extended; an inactive one is reactivated only while the application is below its maximum number of active instances (400 MAX_INSTANCES_REACHED otherwise). A user with access to the application can call it too.
A conversation of another application, or of another instance, is refused with 403. Users keep their usual rules: they read their own conversations on agents they can chat with.
Authentication errorsβ
| Status | Meaning |
|---|---|
401 Unauthorized | The request carries no valid credentials. Body: { "code": "UNAUTHORIZED", "message": "Unauthorized" }. |
403 Forbidden | The credentials are valid but do not grant access to the requested resource (for example: not a member of the organization, not an organization admin, or no access to the agent or app). Body: { "code": "FORBIDDEN", "message": "Forbidden" }, or a more specific sentence. |
See Errors for the error body used by every failed call.
Request identifiersβ
Every response carries an x-request-id header. You may send your own x-request-id; it is reused. Quote this value when contacting support about a specific call.
Verifying tokensβ
Should you verify the validity of a token (signature), you can retrieve the public keys used to sign the JWT at the standard well-known URL:
GET https://api.breign.eu/.well-known/jwks.json
Response
{"keys":[{"crv":"Ed25519","x":"jHvgGLn-OtR36ahB8hcTiCw1f6jtuwwSidhNr0juZo4","kty":"OKP","alg":"Ed25519"}]}
Specificationsβ
We do publish a openapi generated typescript client, you can install it via
npm install --save @breign/client
Inside the installed package is an openapi.json file.
While you can call the endpoints specified directly using any HTTP request library, we recommend you use the client functions as much as possible as those are properly typed and kept up to date.