Status codes and error reasons

Updated

HTTP status codes, error reasons, and retry guidance for Conversational AI Platform REST API requests.

Preview documentation

You're reading the Conversational AI Platform (Preview) docs. Switch to Main.

Use the HTTP status code together with the reason and detail fields in the response body to troubleshoot failed Conversational AI Platform REST API requests.

Error response format

When a request fails, the response body contains a machine-readable reason and a human-readable detail:

{
  "detail": "Secret set support_prod is referenced by agent 3f6c2a9e-8d1b-4e7a-9c55-0b2f7d1e4a10. Remove the reference before deleting the set.",
  "reason": "SecretSetInUse"
}
  • reason is stable. Branch your error handling on it, not on detail. New reasons may be added, so handle an unknown reason by its HTTP status.
  • detail names the field or resource involved, when there is one. Validation stops at the first problem, so fix it and retry to find any others.
  • Every response includes an Agora-Request-Id header. Include its value when you contact Agora support.

A model provider that times out or rejects a key doesn't fail the request that starts a session. The session starts, and the failure surfaces at runtime.

HTTP status codes

Status codeDescriptionSuggested action
200OKThe request was successful.
201CreatedThe resource was created. The response body contains it. Starting a session returns 200 instead.
400Invalid requestFix the request based on reason and detail, then send it again.
401Authentication failedCheck your credentials.
403Access deniedCheck that the service is enabled for the project and that your credentials have permission for the request.
404Not foundCheck the App ID, and the ID or name in the request.
409ConflictCheck the state of the resource. For example, cancel a campaign before you delete it.
405Method not allowedCheck the HTTP method for the endpoint.
412Precondition failedRetrieve the resource, apply your change again, and retry with the new ETag.
413Payload too largeSend a smaller request body.
415Unsupported media typeSend the body as JSON with Content-Type: application/json.
422Quota exceededDelete resources you no longer need, such as secret sets, or contact Agora support to raise your quota.
429Too many requestsRetry with exponential backoff.
500Internal errorRetry with exponential backoff. If the problem persists, contact Agora support.
502Upstream errorRetry with exponential backoff.
503Service unavailableRetry with exponential backoff.
504Operation timeoutRetrieve or list sessions before you retry, because the operation may still complete.

Error reasons

Request errors

ReasonStatusDescription
InvalidRequestBody400The body isn't valid JSON, doesn't match the request format, or contains an unknown field.
MissingRequiredField400A required field, query parameter, or header, such as If-Match, is missing. Also returned when a session or campaign contact has no value for a required variable.
InvalidFieldValue400A value has the wrong type, is out of range, has the wrong format, or isn't allowed.
InvalidModuleParameter400The agent's pipeline is invalid as a whole, for example a parameter value the model service rejects. An unsupported provider, model, or credential mode returns InvalidFieldValue instead.
UnknownSecretReference400A $secrets.<set>.<key> reference names a secret set or key that doesn't exist in the project.
NotImplemented400The field, value, or operation isn't available yet, or the provider doesn't support the action. Don't retry.
MethodNotAllowed405The HTTP method isn't supported for this path. Returned by phone number endpoints. Other endpoints return 405 with NotImplemented.
PayloadTooLarge413The request body is too large. Returned by phone number endpoints. Other endpoints return 413 with InvalidRequestBody.
UnsupportedMediaType415The request body isn't sent as application/json. Returned by phone number endpoints. Other endpoints return 415 with InvalidRequestBody.
UpstreamRejected4xxThe telephony service rejected the phone number's configuration. Returned only by phone number endpoints, with the status code that the telephony service returned. Fix the request based on detail, then send it again.

Access errors

ReasonStatusDescription
InvalidPermission401Authentication is missing or invalid.
InvalidPermission403The credentials don't have permission for the request. A project that doesn't belong to your account returns 404 ResourceNotFound instead.
ServiceNotEnabled403Conversational AI isn't enabled for the project.
AccountSuspended403The account is suspended.

Resource errors

ReasonStatusDescription
ResourceNotFound404The project, agent, secret set, secret key, phone number, or campaign in the path doesn't exist, or the project doesn't belong to your account.
TaskNotFound404The session in the path doesn't exist.
AgentNotFound404An agent in the request body, in agent_id or inbound.agent, doesn't exist.
NumberNotFound404A number in transport.from doesn't exist in the project.
ResourceQuotaLimitExceeded422A quota was reached. For example, the account has reached its number of secret sets.

Conflict and precondition errors

ReasonStatusDescription
TaskConflict409Another operation on the session is in progress. For example, an agent is already running with the same RTC channel and UID, or the session is already stopping. Retry after the other operation finishes.
TaskNotRunning409The session has ended or isn't running yet, so you can't update it.
IdempotencyKeyConflict409A session was already started with this Idempotency-Key. Don't retry. List sessions to find it.
SecretSetAlreadyExists409A secret set with this name already exists. To change its values, update the set.
SecretSetInUse409An agent references the secret set, or a key you're removing from it. detail names the agent. Remove the reference first.
SecretSetEmpty409The change would remove every key from the secret set. To remove every key, delete the set.
NumberAlreadyExists409The phone number is already registered in the project.
AgentInUse409A phone number's inbound routing or an unfinished campaign references the agent you're deleting. detail names the reference. Remove it first.
ResourceConflict409The phone number conflicts with another resource: it's registered to another account, another project in your account routes its inbound calls to an agent, or an unfinished campaign calls from the number you're deleting.
CampaignNotEditable409The campaign has started dialing, so only pacing can change. A completed, canceled, or failed campaign can't change at all.
CampaignActive409The campaign is scheduled, running, or paused, or it still has calls in progress. Cancel it, and wait for its calls to end before you delete it.
CampaignInvalidState409The action isn't allowed in the campaign's current status. For example, you can only pause a running campaign.
PreconditionFailed412The If-Match value doesn't match the current ETag, or you sent If-None-Match: * for a key that exists.

Limit and server errors

ReasonStatusDescription
RateLimitExceeded429Too many requests. Retry with exponential backoff.
ConcurrencyLimitExceeded429The project has reached its concurrent session limit. Stop a session, or retry later with exponential backoff.
InternalError500Something failed on Agora's side. Retry with exponential backoff, and report the Agora-Request-Id if it persists.
ServiceUnavailable502An upstream Agora service returned an invalid response. Retry with exponential backoff.
ServiceUnavailable503A required service is temporarily unavailable. Retry with exponential backoff.
ResourceAllocationFailed503No capacity is available to start the session. Retry with exponential backoff.
TaskOperationTimeout504Starting or stopping the session didn't finish in time, and it may still complete. Retrieve or list sessions before you retry.

Retry safely

  • For 4xx errors, don't retry the same request. Fix it, or change the state it conflicts with. The exceptions are 409 TaskConflict and 429.
  • For 500, 502, and 503 errors, retry with exponential backoff. When you retry a session start, keep the same Idempotency-Key, so the session can't start twice. If the retry fails with 409 IdempotencyKeyConflict, the first request started the session.
  • For 504 TaskOperationTimeout, retrieve or list sessions before you retry, so that you don't start a duplicate session.