CircleCI API (v2)

Download OpenAPI specification:Download

License: MIT

This describes the resources that make up the CircleCI API v2.

Authentication

api_key_query

DEPRECATED - we will remove this option in the future

Security Scheme Type API Key
Query parameter name: circle-token

api_key_header

Security Scheme Type API Key
Header parameter name: Circle-Token

basic_auth

HTTP basic authentication. The username should be set as the circle-token value, and the password should be left blank. Note that project tokens are currently not supported on API v2.

Security Scheme Type HTTP
HTTP Authorization Scheme basic

Context (Preview)

List contexts

List all contexts for an owner.

query Parameters
owner-id
string <uuid>

The unique ID of the owner of the context. Specify either this or owner-slug.

owner-slug
string

A string that represents an organization. Specify either this or owner-id. Cannot be used for accounts.

owner-type
string
Enum: "account" "organization"

The type of the owner. Defaults to "organization". Accounts are only used as context owners in server.

page-token
string

A token to retrieve the next page of results.

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://circleci.com/api/v2/context',
  qs: {
    'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',
    'page-token': 'next_page_token'
  },
  headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "items":
    [
    ],
  • "next_page_token": "string"
}

Create a new context

Request Body schema: application/json
name
required
string

The user defined name of the context.

required
object or object

Responses

Request samples

Content type
application/json
{
  • "name": "string",
  • "owner":
    {
    }
}

Response samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "name": "string",
  • "created_at": "2015-09-21T17:29:21.042Z"
}

Delete a context

path Parameters
context-id
required
string <uuid>

ID of the context (UUID)

Responses

Request samples

const request = require('request');

const options = {
  method: 'DELETE',
  url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D',
  headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "message": "string"
}

Get a context

Returns basic information about a context.

path Parameters
context-id
required
string <uuid>

ID of the context (UUID)

Responses

Request samples

const request = require('request');

const options = {
  method: 'GET',
  url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D',
  headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}
};

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response samples

Content type
application/json
{
  • "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  • "name": "string",
  • "created_at": "2015-09-21T17:29:21.042Z"
}

List environment variables

List information about environment variables in a context, not including their values.

path Parameters
context-id
required
string <uuid>

ID of the context (UUID)

Responses