API Conventions

Understand the status codes, error formats, and response structures returned by the Evals 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

1{
2 "success": true,
3 "data": {
4 // Response payload specific to the endpoint
5 },
6 "deprecated": false,
7 "link": "https://app.confident-ai.com/..."
8}
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

1{
2 "success": false,
3 "error": "Error message describing what went wrong",
4 "deprecated": false
5}
FieldTypeDescription
successbooleanAlways false for error responses
errorstringA human-readable message describing the error
deprecatedbooleanIndicates if this endpoint is deprecated

HTTP Status Codes

The Evals 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.

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.

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:

1{
2 "success": true,
3 "data": {
4 "testRunId": "abc123"
5 },
6 "deprecated": false
7}

And tomorrow it returns:

1{
2 "success": true,
3 "data": {
4 "testRunId": "abc123",
5 "newField": "some value"
6 },
7 "deprecated": false
8}

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.

When deserializing responses, configure your parser to ignore unknown properties. In Python with Pydantic, use extra = "ignore". In TypeScript, avoid strict object type assertions.

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

Deprecated endpoints will continue to function for a transition period, but may be removed in future API versions. Always migrate to recommended alternatives when you see deprecation notices.