API Conventions
Understand the status codes, error formats, and response structures returned by the Confident API
Overview
All API endpoints follow consistent conventions for response formats, status codes, and error handling. This page documents what to expect when making requests to the API.
Request Headers
All API requests require the following headers:
| Header | Required | Description |
|---|---|---|
CONFIDENT_API_KEY | Yes | Your project/organizatioin API key for authentication (API key type depends on endpoint) |
Content-Type | Yes | Must be application/json for requests with a body |
curl -X POST https://api.confident-ai.com/v1/... \
-H "CONFIDENT_API_KEY: your-api-key" \
-H "Content-Type: application/json" \
-d '{ ... }'Response Format
All API responses follow a consistent JSON structure:
Success response
{
"success": true,
"data": {
// Response payload specific to the endpoint
},
"deprecated": false,
"link": "https://app.confident-ai.com/..."
}| Field | Type | Description |
|---|---|---|
success | boolean | Always true for successful requests |
data | object | The response payload, varies by endpoint |
deprecated | boolean | Indicates if this endpoint is deprecated. If true, migrate to the recommended alternative |
link | string | (Optional) URL to the created/relevant resource on the Confident AI platform |
Error response
{
"success": false,
"error": "Error message describing what went wrong",
"deprecated": false
}| Field | Type | Description |
|---|---|---|
success | boolean | Always false for error responses |
error | string | A human-readable message describing the error |
deprecated | boolean | Indicates if this endpoint is deprecated |
HTTP Status Codes
The Confident API uses standard HTTP status codes to indicate the success or failure of requests.
Success codes
| Status Code | Description |
|---|---|
200 OK | The request was successful |
201 Created | A new resource was successfully created |
Client error codes
| Status Code | Name | Description |
|---|---|---|
400 | Bad Request | The request was malformed or contained invalid parameters. Check your request body and query parameters. |
401 | Unauthorized | Authentication failed. Verify your API key is correct and included in the request headers. |
403 | Forbidden | You don't have permission to access this resource. Check your API key permissions and project access. |
404 | Not Found | The requested resource doesn't exist. Verify the resource ID or path is correct. |
409 | Conflict | The request conflicts with the current state of the resource. This often occurs when creating a resource that already exists. |
422 | Unprocessable Entity | The request was well-formed but contains semantic errors. Check that your data meets all validation requirements. |
429 | Too Many Requests | You've exceeded your organization's rate limit or your project's trace storage limit. See rate limits. |
Server error codes
| Status Code | Name | Description |
|---|---|---|
500 | Internal Server Error | An unexpected error occurred on our servers. If this persists, contact support. |
503 | Maintenance | The API is temporarily unavailable due to scheduled maintenance. Check our status page for updates. |
Rate Limits
The API allows 4,000 requests per minute per organization. The limit is shared by all of the organization's API keys and its members' sessions in the Confident AI app. Every response to an authenticated request includes headers that show where you stand in the current window:
| Header | Description |
|---|---|
RateLimit-Limit | Requests allowed per window (4000) |
RateLimit-Remaining | Requests left in the current window |
RateLimit-Reset | Seconds until the current window resets |
Once your organization goes over, requests return 429 with a Retry-After header (in seconds) until the window resets:
{
"success": false,
"error": "Rate limit exceeded for this organization. Please retry after 42 seconds.",
"deprecated": false
}When you get a 429, wait for Retry-After before sending more requests.
Failed authentication
Requests with an invalid API key are limited separately, by IP address. After 30 failed attempts from the same IP within 5 minutes, every request from that IP that includes an API key returns 429 until the 5 minutes are up, even with a valid key.
Trace storage limit
The trace ingestion endpoints also count the size of every request toward your project's Trace Storage usage limit. Once a project reaches it, every trace request returns 429 until the next billing cycle starts or the limit is raised, so retrying doesn't help:
{
"success": false,
"error": "Trace storage usage limit reached for this billing cycle. Lower data retention or raise the project's traceStorageLimits to keep ingesting.",
"deprecated": false,
"details": {
"usage": "1",
"limit": "1"
}
}usage and limit are in GB. On the Free plan and during a trial, the limit is 1 GB-month, whatever the project's own limit is set to.
Ensure Forward Compatibility
We may add new fields to the data field of API responses at any time without considering it a breaking change.
To ensure your integration remains stable, your client should ignore unknown fields rather than failing when encountering them.
For example, if today an endpoint returns:
{
"success": true,
"data": {
"testRunId": "abc123"
},
"deprecated": false
}And tomorrow it returns:
{
"success": true,
"data": {
"testRunId": "abc123",
"newField": "some value"
},
"deprecated": false
}Your client should continue to work without modification. Most JSON parsing libraries handle this by default, but be cautious if you're using strict schema validation.
Deprecation Notices
When an endpoint is deprecated, responses will include "deprecated": true. We recommend:
- Monitor the
deprecatedfield in all responses - Plan to migrate to the recommended alternative before the endpoint is removed
Last updated on