Skip to main content

Endpoint

GET /api/v1/contracts
Host: api.driftguard.dev

Request

curl -s https://api.driftguard.dev/api/v1/contracts \
  -H "X-API-Key: $DRIFTGUARD_KEY"

Response

[
  {
    "id": "your_contract_id_here",
    "name": "users_production",
    "version": 1,
    "schema": {
      "columns": [
        { "name": "user_id",    "type": "integer",   "required": true },
        { "name": "email",      "type": "string",    "required": true },
        { "name": "created_at", "type": "timestamp", "required": true }
      ]
    },
    "created_at": "2026-03-01T18:00:00Z",
    "updated_at": "2026-03-01T18:00:00Z"
  },
  {
    "id": "your_second_contract_id_here",
    "name": "orders_production",
    "version": 2,
    "schema": {
      "columns": [
        { "name": "order_id",  "type": "integer", "required": true },
        { "name": "status",    "type": "string",  "required": true },
        { "name": "total",     "type": "number",  "required": false }
      ]
    },
    "created_at": "2026-03-01T17:00:00Z",
    "updated_at": "2026-03-02T09:00:00Z"
  }
]

Response Fields

Each object in the array has the following fields:
FieldTypeDescription
idstringUnique identifier for the contract
namestringThe name given to the contract
versionintegerCurrent version number — increments each time the contract schema is updated
schema.columnsarrayFull list of column definitions
schema.columns[].namestringColumn name (case-sensitive)
schema.columns[].typestringColumn type — one of string, integer, number, boolean, date, timestamp, json
schema.columns[].requiredbooleanWhether the column must be present in every check
created_atstringISO 8601 timestamp of when the contract was created
updated_atstringISO 8601 timestamp of the last update
Results are scoped to your account — you will only ever see contracts created with your API key. Pagination support is planned for a future release.

Error Responses

StatusMeaning
401Missing or invalid X-API-Key
429Rate limit exceeded — 100 req/min per key

Create Contract

Define a new expected schema as a contract.

Get Contract

Retrieve a single contract by its ID.