Spectacles API (1.0.0)
This documentation explains how to interact with Spectacles via our REST API.
Click on any API endpoint route to expand it into a full URL. For example, /runs
will expand into https://app.spectacles.dev/api/v1/runs
.
Bearer Token
To get started, follow this guide to create an API key.
To authenticate to the Spectacles API, you'll need to obtain a token from the Settings page of the Spectacles application. You can only have one API token active at a time, so be sure to store it securely. If you lose it, you'll need to replace it with a new one.
Once you have the token, pass it in the header of your API calls as a bearer token, like this: Authorization: Bearer <token>
Security Scheme Type | HTTP |
---|---|
HTTP Authorization Scheme | bearer |
Bearer format | "JWT" |
Get a run
Retrieve the details for a given run, including:
- The current status (queued, running, success, etc.)
- The result of each validator (if available)
- Metadata about the run
You can easily find the organisation, project, and run IDs in the URL of the run details page within the Spectacles app.
Authorizations:
path Parameters
orgId required | string The ID of the organisation the run belongs to. Find this in the URL of the run after |
projectId required | string The ID of the project the run belongs to. Find this in the URL of the run after |
runId required | string The ID of the run to get. Find this in the URL of the run after |
Responses
Response samples
- 200
- 401
- 403
- 404
- 500
{- "org_id": "string",
- "project_id": "string",
- "run_id": "string",
- "suite_id": "string",
- "suite_name": "string",
- "url": "string",
- "result": [
- {
- "status": null,
- "validator": null
}
], - "ref": {
- "type": null,
- "value": null
}, - "created_at": "string",
- "started_at": "string",
- "finished_at": "string",
- "status": "string",
- "trigger": "string",
- "user_attributes": { }
}
Create a new run
Create a run belonging to a given organisation, project, and suite. Return the ID of the newly created run as well as its status at time of creation.
To create a run against production, omit branch
and commit
from your request.
You can easily find the organisation, project, and suite IDs in the URL of the suite page within the Spectacles app.
Authorizations:
Request Body schema: application/json
org_id required | string The ID of the organisation to create the run in. Find this in the URL of the Suite after |
project_id required | string The ID of the project to create the run in. Find this in the URL of the Suite after |
suite_id required | string The ID of the suite to use. Find this in the URL of the Suite after |
branch | string The branch to test. Omit to test production. |
target | string For incremental runs only. The branch or commit to compare against for incremental validation. When |
commit | string The commit to test. Omit to test production. |
user_attributes | object To set user attributes for your run, specify them here as key/value pairs. These user attributes must first be configured up in your Spectacles settings. |
Array of any[ items ] Send a webhook when the run completes. The behavior of the webhook depends on the type specified. Specify a |
Responses
Request samples
- Payload
{- "org_id": "XstGk40FKAhElMNPMiZ9",
- "project_id": "KFmxNOfdWj0A60A6zqE6",
- "suite_id": "cMHbCPeWokwVhgqAh9AZ",
- "commit": "ea23ba",
- "target": "develop",
- "user_attributes": {
- "dbt_project": "spectacles",
- "dbt_dataset": "analytics"
}, - "webhooks": [
- {
- "type": "github",
- "commit": "abc123",
- "repo": "spectacles-ci/spectaces-dbt"
}
]
}
Response samples
- 200
- 401
- 403
- 404
- 500
{- "run_id": "string",
- "status": "string"
}