Launch Week 3: Five days of launches

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:

HeaderRequiredDescription
CONFIDENT_API_KEYYesYour project/organizatioin API key for authentication (API key type depends on endpoint)
Content-TypeYesMust 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/..."
}
FieldTypeDescription
successbooleanAlways true for successful requests
dataobjectThe response payload, varies by endpoint
deprecatedbooleanIndicates if this endpoint is deprecated. If true, migrate to the recommended alternative
linkstring(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
}
FieldTypeDescription
successbooleanAlways false for error responses
errorstringA human-readable message describing the error
deprecatedbooleanIndicates 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 CodeDescription
200 OKThe request was successful
201 CreatedA new resource was successfully created

Client error codes

Status CodeNameDescription
400Bad RequestThe request was malformed or contained invalid parameters. Check your request body and query parameters.
401UnauthorizedAuthentication failed. Verify your API key is correct and included in the request headers.
403ForbiddenYou don't have permission to access this resource. Check your API key permissions and project access.
404Not FoundThe requested resource doesn't exist. Verify the resource ID or path is correct.
409ConflictThe request conflicts with the current state of the resource. This often occurs when creating a resource that already exists.
422Unprocessable EntityThe request was well-formed but contains semantic errors. Check that your data meets all validation requirements.
429Too Many RequestsYou've exceeded your organization's rate limit or your project's trace storage limit. See rate limits.

Server error codes

Status CodeNameDescription
500Internal Server ErrorAn unexpected error occurred on our servers. If this persists, contact support.
503MaintenanceThe 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:

HeaderDescription
RateLimit-LimitRequests allowed per window (4000)
RateLimit-RemainingRequests left in the current window
RateLimit-ResetSeconds 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:

  1. Monitor the deprecated field in all responses
  2. Plan to migrate to the recommended alternative before the endpoint is removed
Building a production pipeline?Design a scalable API workflow for evals, datasets, traces, and promptsTalk to an engineer

Last updated on

Built byConfident AI