Skip to content

Instantly share code, notes, and snippets.

@jSherz
Created May 1, 2024 07:51
Show Gist options
  • Save jSherz/f57aa6ad9c0e9c03a72a27010dede3e3 to your computer and use it in GitHub Desktop.
Save jSherz/f57aa6ad9c0e9c03a72a27010dede3e3 to your computer and use it in GitHub Desktop.
{
"openapi": "3.0.3",
"info": {
"version": "v2",
"title": "CircleCI API",
"description": "This describes the resources that make up the CircleCI API v2.\n\n# Authentication\n\n<!-- ReDoc-Inject: <security-definitions> -->",
"license": {
"name": "MIT"
}
},
"servers": [
{
"url": "https://circleci.com/api/v2"
}
],
"security": [
{
"api_key_header": []
},
{
"basic_auth": []
},
{
"api_key_query": []
}
],
"tags": [
{
"name": "Context"
},
{
"name": "Insights"
},
{
"name": "User"
},
{
"name": "Pipeline"
},
{
"name": "Job"
},
{
"name": "Workflow"
},
{
"name": "Webhook"
},
{
"description": "Endpoints related to manage oidc identity tokens",
"name": "OIDC Token Management"
},
{
"description": "Endpoints related to managing policies and making policy decisions",
"name": "Policy Management"
},
{
"name": "Project",
"description": "[__EXPERIMENTAL__] Endpoints related to creating and managing a project."
},
{
"name": "Usage",
"description": "[__EXPERIMENTAL__] Endpoints related to organization usage exports.\n\nThe Usage API is an API provided by CircleCI to customers to access all of their usage data on CircleCI. It contains all the metadata (org, project, pipeline, workflow, and job dimensions) as well as credit consumption data. It is provided at the near lowest level of granularity (at the job run level).\n\n__Restrictions__\n\n* Max result set size of 100MB\n* Query timeout of 4 hours.\n* Max date window of 32 days\n* No PII is surfaced in the Usage API (e.g. email address, Github login name)\n* The POST endpoint can only be queried up to (i.e. is rate limited to) 10 times per hour per org\n* The GET endpoint can only be queried up to (i.e. is rate limited to) 10 times per minute per org\n* To increase performance the API can generate multiple CSV files that need to be merged after download\n\n__Requirements__\n\n* organization ID - To get your organization ID go to to Organization Settings tab in the CircleCI app. ie https://app.circleci.com/settings/organization/<vcs>/<org name>/overview\n* API Personal Access Token - https://circleci.com/docs/managing-api-tokens/\n\n__Report Fields__\n\n| | Field | Description |\n|---------------------------------------|-------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | organization_id | The org ID |\n| | organization_name | The org name |\n| | organization_created_date | The date that the org was created |\n| Project-level attributes | project_id | The project ID / token |\n| | project_name | The project name. For classic orgs, the project name is inherited from Github. For standalone, the org is set by the user. |\n| | project_created_date | The date that the project was created. For classic orgs, this is the date that the repo was authorized on CircleCI. For standalone orgs, this is the date that the project was created on CircleCI |\n| | last_build_finished_at | The date of the last pipeline run on this project |\n| Pipeline-level attributes | vcs_name | The name of the VCS connected to the project on which the pipeline was run |\n| | vcs_url | The URL of the VCS on which the pipeline was run |\n| | vcs_branch | The branch on which the pipeline was run |\n| | pipeline_id | The ID of the pipeline instance that was triggered. If a pipeline is re-run, it will share the same pipeline ID as the original pipeline instance |\n| | pipeline_created_at | The date the pipeline instance was first triggered |\n| | pipeline_number | The pipeline number |\n| | is_unregistered_user | Y/N flag of whether the pipeline was triggered by a CircleCI user or a user not registered on CircleCI. Examples of the latter include users who commit on a connected VCS and consume credits on CircleCI. |\n| | pipeline_trigger_source | The source of the pipeline instance trigger (API, webhook, etc.) |\n| | pipeline_trigger_user_id | The user ID / token of the user who triggered the pipeline |\n| Workflow-level attributes | workflow_id | The ID of the workflow instance that was triggered |\n| | workflow_name | The name of the workflow |\n| | workflow_first_job_queued_at | The timestamp of when the workflow instance started to queue |\n| | workflow_first_job_started_at | The timestamp of when the workflow instance started to run |\n| | workflow_stopped_at | The timestamp of when the workflow instance stopped |\n| | is_workflow_successful | Y/N flag of whether all jobs in the workflow were successfully ran |\n| Job-level attributes | job_name | The name of the job (the name the customer sees in the UI) |\n| | job_id | The ID of the job run instance that was triggered |\n| | job_run_number | The number of the job run instance that was triggered |\n| | job_run_date | The date of the job run instance began |\n| | job_build_status | The status of the job run instance |\n| | resource_class | The resource class of the job run instance |\n| | operating_system | The operating system of the job run instance |\n| | executor | The executor of the job run instance |\n| | parallelism | The parallelism of the job run instance |\n| | job_run_seconds | The duration in seconds of the job run instance |\n| | median_cpu_utilization_pct | The median CPU utilization calculated over the course of the entire job run instance. CPU utilization is logged every 15 seconds. It will not be available for any jobs under 15 seconds and occasionally will not be available for jobs greater than 15 seconds. |\n| | max_cpu_utilization_pct | The max CPU utilization logged over the course of the entire job run instance. CPU utilization is logged every 15 seconds. It will not be available for any jobs under 15 seconds and occasionally will not be available for jobs greater than 15 seconds. |\n| | median_ram_utilization_pct | The median RAM utilization calculated over the course of the entire job run instance. RAM utilization is logged every 15 seconds. It will not be available for any jobs under 15 seconds and occasionally will not be available for jobs greater than 15 seconds. |\n| | max_ram_utilization_pct | The max RAM utilization logged over the course of the entire job run instance. RAM utilization is logged every 15 seconds. It will not be available for any jobs under 15 seconds and occasionally will not be available for jobs greater than 15 seconds. |\n| Credit consumption metrics | compute_credits | The compute credits consumed by this job run instance |\n| | dlc_credits | The docker-layer caching credits consumed by this job run instance |\n| | user_credits | The user credits consumed by this job run instance |\n| | storage_credits | The storage credits consumed by this job run instance |\n| | network_credits | The network credits consumed by this job run instance |\n| | lease_credits | The lease credits consumed by this job run instance |\n| | lease_overage_credits | The lease overage credits consumed by this job run instance |\n| | ipranges_credits | The IP ranges credits consumed by this job run instance |\n| | total_credits | The total credits consumed by this job run instance |\n"
}
],
"paths": {
"/context": {
"get": {
"summary": "List contexts",
"description": "List all contexts for an owner.",
"tags": [
"Context"
],
"operationId": "listContexts",
"responses": {
"200": {
"description": "A paginated list of contexts",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the context."
},
"name": {
"type": "string",
"description": "The user defined name of the context."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the context was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"id",
"name",
"created_at"
],
"title": "Context"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
]
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "query",
"name": "owner-id",
"description": "The unique ID of the owner of the context. Specify either this or owner-slug.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": false
},
{
"in": "query",
"name": "owner-slug",
"description": "A string that represents an organization. Specify either this or owner-id. Cannot be used for accounts.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "owner-type",
"description": "The type of the owner. Defaults to \"organization\". Accounts are only used as context owners in server.",
"schema": {
"type": "string",
"enum": [
"account",
"organization"
]
},
"required": false
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context',\n qs: {\n 'owner-id': 'c65b68ef-e73b-4bf2-be9a-7a322a9df150',\n 'page-token': 'NEXT_PAGE_TOKEN'\n },\n headers: {'Circle-Token': 'CIRCLE_TOKEN'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection('circleci.com')\n\nheaders = { 'Circle-Token': 'CIRCLE_TOKEN' }\n\nconn.request('GET', '/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=NEXT_PAGE_TOKEN', headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode('utf-8'))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=NEXT_PAGE_TOKEN\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"Circle-Token\", \"CIRCLE_TOKEN\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=NEXT_PAGE_TOKEN' \\\n --header \"Circle-Token: ${CIRCLE_TOKEN}\""
},
{
"lang": "Ruby + Native",
"source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI('https://circleci.com/api/v2/context?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=NEXT_PAGE_TOKEN')\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Get.new(url)\nrequest['Circle-Token'] = 'CIRCLE_TOKEN'\n\nresponse = http.request(request)\nputs response.read_body"
}
]
},
"post": {
"summary": "Create a new context",
"description": "Creates a new context.",
"tags": [
"Context"
],
"operationId": "createContext",
"responses": {
"200": {
"description": "The new context",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the context."
},
"name": {
"type": "string",
"description": "The user defined name of the context."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the context was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"id",
"name",
"created_at"
],
"title": "Context"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The user defined name of the context."
},
"owner": {
"oneOf": [
{
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the owner of the context. Specify either this or slug."
},
"type": {
"enum": [
"account",
"organization"
],
"type": "string",
"description": "The type of the owner. Defaults to \"organization\". Accounts are only used as context owners in server.",
"example": "organization"
}
},
"required": [
"id"
]
},
{
"type": "object",
"properties": {
"slug": {
"type": "string",
"description": "A string that represents an organization. Specify either this or id. Cannot be used for accounts."
},
"type": {
"enum": [
"organization"
],
"type": "string",
"description": "The type of owner. Defaults to \"organization\". Accounts are only used as context owners in server and must be specified by an id instead of a slug."
}
},
"required": [
"slug"
]
}
]
}
},
"required": [
"name",
"owner"
]
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/context',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {name: 'string', owner: {id: 'string', type: 'organization'}},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"name\\\":\\\"string\\\",\\\"owner\\\":{\\\"id\\\":\\\"string\\\",\\\"type\\\":\\\"organization\\\"}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/context\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context\"\n\n\tpayload := strings.NewReader(\"{\\\"name\\\":\\\"string\\\",\\\"owner\\\":{\\\"id\\\":\\\"string\\\",\\\"type\\\":\\\"organization\\\"}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/context \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"string\",\"owner\":{\"id\":\"string\",\"type\":\"organization\"}}'"
}
]
}
},
"/context/{context-id}": {
"delete": {
"summary": "Delete a context",
"tags": [
"Context"
],
"operationId": "deleteContext",
"responses": {
"200": {
"description": "A confirmation message",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "context-id",
"description": "ID of the context (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/context/%7Bcontext-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/%7Bcontext-id%7D\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/context/%7Bcontext-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"summary": "Get a context",
"description": "Returns basic information about a context.",
"tags": [
"Context"
],
"operationId": "getContext",
"responses": {
"200": {
"description": "The context",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the context."
},
"name": {
"type": "string",
"description": "The user defined name of the context."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the context was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"id",
"name",
"created_at"
],
"title": "Context"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "context-id",
"description": "ID of the context (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/context/%7Bcontext-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/%7Bcontext-id%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/context/%7Bcontext-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/context/{context-id}/environment-variable": {
"get": {
"summary": "List environment variables",
"description": "List information about environment variables in a context, not including their values.",
"tags": [
"Context"
],
"operationId": "listEnvironmentVariablesFromContext",
"responses": {
"200": {
"description": "A paginated list of environment variables",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"variable": {
"type": "string",
"description": "The name of the environment variable",
"example": "POSTGRES_USER"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the environment variable was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the environment variable was updated",
"example": "2015-09-21T17:29:21.042Z"
},
"context_id": {
"type": "string",
"format": "uuid",
"description": "ID of the context (UUID)"
}
},
"required": [
"variable",
"created_at",
"updated_at",
"context_id"
]
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
]
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "context-id",
"description": "ID of the context (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable',\n qs: {'page-token': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/context/%7Bcontext-id%7D/environment-variable?page-token=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable?page-token=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable?page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/context/{context-id}/environment-variable/{env-var-name}": {
"put": {
"summary": "Add or update an environment variable",
"description": "Create or update an environment variable within a context. Returns information about the environment variable, not including its value.",
"tags": [
"Context"
],
"operationId": "addEnvironmentVariableToContext",
"responses": {
"200": {
"description": "The new environment variable",
"content": {
"application/json": {
"schema": {
"anyOf": [
{
"type": "object",
"properties": {
"variable": {
"type": "string",
"description": "The name of the environment variable",
"example": "POSTGRES_USER"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the environment variable was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the environment variable was updated",
"example": "2015-09-21T17:29:21.042Z"
},
"context_id": {
"type": "string",
"format": "uuid",
"description": "ID of the context (UUID)"
}
},
"required": [
"variable",
"created_at",
"updated_at",
"context_id"
]
},
{
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
]
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "context-id",
"description": "ID of the context (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
},
{
"in": "path",
"name": "env-var-name",
"description": "The name of the environment variable",
"schema": {
"type": "string"
},
"required": true,
"example": "POSTGRES_USER"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"value": {
"type": "string",
"description": "The value of the environment variable",
"example": "some-secret-value"
}
},
"required": [
"value"
]
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PUT',\n url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {value: 'some-secret-value'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"value\\\":\\\"some-secret-value\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PUT\", \"/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\"\n\n\tpayload := strings.NewReader(\"{\\\"value\\\":\\\"some-secret-value\\\"}\")\n\n\treq, _ := http.NewRequest(\"PUT\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PUT \\\n --url https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"value\":\"some-secret-value\"}'"
}
]
},
"delete": {
"summary": "Remove an environment variable",
"description": "Delete an environment variable from a context.",
"tags": [
"Context"
],
"operationId": "deleteEnvironmentVariableFromContext",
"responses": {
"200": {
"description": "A confirmation message",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "env-var-name",
"description": "The name of the environment variable",
"schema": {
"type": "string"
},
"required": true,
"example": "POSTGRES_USER"
},
{
"in": "path",
"name": "context-id",
"description": "ID of the context (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/pages/{project-slug}/summary": {
"get": {
"summary": "Get summary metrics and trends for a project across it's workflows and branches",
"description": "Get summary metrics and trends for a project at workflow and branch level.\n Workflow runs going back at most 90 days are included in the aggregation window.\n Trends are only supported upto last 30 days.\n Please note that Insights is not a financial reporting tool and should not be used for precise credit reporting. Credit reporting from Insights does not use the same source of truth as the billing information that is found in the Plan Overview page in the CircleCI UI, nor does the underlying data have the same data accuracy guarantees as the billing information in the CircleCI UI. This may lead to discrepancies between credits reported from Insights and the billing information in the Plan Overview page of the CircleCI UI. For precise credit reporting, always use the Plan Overview page in the CircleCI UI.",
"tags": [
"Insights"
],
"operationId": "getProjectWorkflowsPageData",
"responses": {
"200": {
"description": "Aggregated summary metrics and trends by workflow and branches",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"org_id": {
"description": "The unique ID of the organization"
},
"project_id": {
"description": "The unique ID of the project"
},
"project_data": {
"type": "object",
"properties": {
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"total_duration_secs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "Total duration, in seconds."
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"success_rate": {
"type": "number",
"format": "float"
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
}
},
"required": [
"total_runs",
"total_duration_secs",
"total_credits_used",
"success_rate",
"throughput"
],
"description": "Metrics aggregated across all workflows and branches for a project."
},
"trends": {
"type": "object",
"properties": {
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"total_duration_secs": {
"type": "number",
"format": "float",
"description": "Trend value for total duration."
},
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
},
"throughput": {
"type": "number",
"format": "float",
"description": "Trend value for the average number of runs per day."
}
},
"required": [
"total_runs",
"total_duration_secs",
"total_credits_used",
"success_rate",
"throughput"
],
"description": "Metric trends aggregated across all workflows and branches for a project."
}
},
"required": [
"metrics",
"trends"
],
"description": "Metrics and trends data aggregated for a given project."
},
"project_workflow_data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"workflow_name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"metrics": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"p95_duration_secs": {
"type": "number",
"format": "float",
"description": "The 95th percentile duration among a group of workflow runs."
},
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"success_rate": {
"type": "number",
"format": "float"
}
},
"required": [
"total_credits_used",
"p95_duration_secs",
"total_runs",
"success_rate"
],
"description": "Metrics aggregated across a workflow or branchfor a project."
},
"trends": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"p95_duration_secs": {
"type": "number",
"format": "float",
"description": "The 95th percentile duration among a group of workflow runs."
},
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
}
},
"required": [
"total_credits_used",
"p95_duration_secs",
"total_runs",
"success_rate"
],
"description": "Trends aggregated across a workflow or branch for a project."
}
},
"required": [
"workflow_name",
"metrics",
"trends"
]
},
"description": "A list of metrics and trends data for workflows for a given project."
},
"project_workflow_branch_data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"workflow_name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"branch": {
"type": "string",
"description": "The VCS branch of a workflow's trigger.",
"example": "main"
},
"metrics": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"p95_duration_secs": {
"type": "number",
"format": "float",
"description": "The 95th percentile duration among a group of workflow runs."
},
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"success_rate": {
"type": "number",
"format": "float"
}
},
"required": [
"total_credits_used",
"p95_duration_secs",
"total_runs",
"success_rate"
],
"description": "Metrics aggregated across a workflow or branchfor a project."
},
"trends": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"p95_duration_secs": {
"type": "number",
"format": "float",
"description": "The 95th percentile duration among a group of workflow runs."
},
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
}
},
"required": [
"total_credits_used",
"p95_duration_secs",
"total_runs",
"success_rate"
],
"description": "Trends aggregated across a workflow or branch for a project."
}
},
"required": [
"workflow_name",
"branch",
"metrics",
"trends"
]
},
"description": "A list of metrics and trends data for branches for a given project."
},
"all_branches": {
"type": "array",
"items": {
"type": "string",
"description": "The VCS branch of a workflow's trigger.",
"example": "main"
},
"description": "A list of all the branches for a given project."
},
"all_workflows": {
"type": "array",
"items": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"description": "A list of all the workflows for a given project."
}
}
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "reporting-window",
"description": "The time window used to calculate summary metrics. If not provided, defaults to last-90-days",
"schema": {
"type": "string",
"enum": [
"last-7-days",
"last-90-days",
"last-24-hours",
"last-30-days",
"last-60-days"
]
},
"required": false,
"example": "last-90-days"
},
{
"in": "query",
"name": "branches",
"description": "The names of VCS branches to include in branch-level workflow metrics.",
"schema": {
"type": "object"
},
"required": false,
"example": "A single branch: ?branches=main or for multiple branches: ?branches=main&branches=feature&branches=dev"
},
{
"in": "query",
"name": "workflow-names",
"description": "The names of workflows to include in workflow-level metrics.",
"schema": {
"type": "object"
},
"required": false,
"example": "A single workflow name: ?workflow-names=build-test-deploy or\n for multiple workflow names: ?workflow-names=build&workflow-names=test-and-deploy."
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/pages/gh/CircleCI-Public/api-preview-docs/summary',\n qs: {\n 'reporting-window': 'SOME_STRING_VALUE',\n branches: 'SOME_OBJECT_VALUE',\n 'workflow-names': 'SOME_OBJECT_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/pages/gh/CircleCI-Public/api-preview-docs/summary?reporting-window=SOME_STRING_VALUE&branches=SOME_OBJECT_VALUE&workflow-names=SOME_OBJECT_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/pages/gh/CircleCI-Public/api-preview-docs/summary?reporting-window=SOME_STRING_VALUE&branches=SOME_OBJECT_VALUE&workflow-names=SOME_OBJECT_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/pages/gh/CircleCI-Public/api-preview-docs/summary?reporting-window=SOME_STRING_VALUE&branches=SOME_OBJECT_VALUE&workflow-names=SOME_OBJECT_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/time-series/{project-slug}/workflows/{workflow-name}/jobs": {
"get": {
"summary": "Job timeseries data",
"description": "Get timeseries data for all jobs within a workflow. Hourly granularity data is only retained for 48 hours while daily granularity data is retained for 90 days.",
"tags": [
"Insights"
],
"operationId": "getJobTimeseries",
"responses": {
"200": {
"description": "An array of timeseries data, one entry per job.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
},
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"min_started_at": {
"type": "string",
"format": "date-time",
"description": "The start time for the earliest execution included in the metrics."
},
"max_ended_at": {
"type": "string",
"format": "date-time",
"description": "The end time of the last execution included in the metrics."
},
"timestamp": {
"type": "string",
"format": "date-time",
"description": "The start of the interval for timeseries metrics."
},
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of failed runs."
},
"successful_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of successful runs."
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
},
"median_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The median credits consumed over the current timeseries interval."
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"duration_metrics": {
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The minimum duration, in seconds, among a group of runs."
},
"median": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The median duration, in seconds, among a group of runs."
},
"max": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The max duration, in seconds, among a group of runs."
},
"p95": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of runs."
},
"total": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The total duration, in seconds, added across a group of runs."
}
},
"required": [
"min",
"median",
"max",
"p95",
"total"
],
"description": "Metrics relating to the duration of runs for a workflow."
}
},
"required": [
"total_runs",
"failed_runs",
"successful_runs",
"throughput",
"median_credits_used",
"total_credits_used",
"duration_metrics"
],
"description": "Metrics relating to a workflow's runs."
}
},
"required": [
"name",
"min_started_at",
"max_ended_at",
"timestamp",
"metrics"
]
},
"description": "Aggregate metrics for a workflow at a time granularity"
}
},
"required": [
"next_page_token",
"items"
],
"description": "Project level timeseries metrics response"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "workflow-name",
"description": "The name of the workflow.",
"schema": {
"type": "string"
},
"required": true,
"example": "build-and-test"
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "granularity",
"description": "The granularity for which to query timeseries data.",
"schema": {
"type": "string",
"enum": [
"daily",
"hourly"
]
},
"required": false,
"example": "hourly"
},
{
"in": "query",
"name": "start-date",
"description": "Include only executions that started at or after this date. This must be specified if an end-date is provided.",
"schema": {
"type": "string",
"format": "date-time"
},
"required": false,
"example": "2020-08-21T13:26:29Z"
},
{
"in": "query",
"name": "end-date",
"description": "Include only executions that started before this date. This date can be at most 90 days after the start-date.",
"schema": {
"type": "string",
"format": "date-time"
},
"required": false,
"example": "2020-09-04T13:26:29Z"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs',\n qs: {\n branch: 'SOME_STRING_VALUE',\n granularity: 'SOME_STRING_VALUE',\n 'start-date': 'SOME_STRING_VALUE',\n 'end-date': 'SOME_STRING_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?branch=SOME_STRING_VALUE&granularity=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?branch=SOME_STRING_VALUE&granularity=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?branch=SOME_STRING_VALUE&granularity=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{org-slug}/summary": {
"get": {
"summary": "Get summary metrics with trends for the entire org, and for each project.",
"description": "Gets aggregated summary metrics with trends for the entire org.\n Also gets aggregated metrics and trends for each project belonging to the org.",
"tags": [
"Insights"
],
"operationId": "getOrgSummaryData",
"responses": {
"200": {
"description": "summary metrics with trends for an entire org and it's projects.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"org_data": {
"type": "object",
"properties": {
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"total_duration_secs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "Total duration, in seconds."
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"success_rate": {
"type": "number",
"format": "float"
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
}
},
"required": [
"total_runs",
"total_duration_secs",
"total_credits_used",
"success_rate",
"throughput"
],
"description": "Metrics for a single org metrics."
},
"trends": {
"type": "object",
"properties": {
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"total_duration_secs": {
"type": "number",
"format": "float",
"description": "Trend value for total duration."
},
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
},
"throughput": {
"type": "number",
"format": "float",
"description": "Trend value for the average number of runs per day."
}
},
"required": [
"total_runs",
"total_duration_secs",
"total_credits_used",
"success_rate",
"throughput"
],
"description": "Trends for a single org."
}
},
"required": [
"metrics",
"trends"
],
"description": "Aggregated metrics for an org, with trends."
},
"org_project_data": {
"type": "array",
"items": {
"type": "object",
"properties": {
"project_name": {
"type": "string",
"description": "The name of the project.",
"example": "api-preview-docs"
},
"metrics": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed over the current timeseries interval."
},
"total_duration_secs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "Total duration, in seconds."
},
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"success_rate": {
"type": "number",
"format": "float"
}
},
"required": [
"total_credits_used",
"total_duration_secs",
"total_runs",
"success_rate"
],
"description": "Metrics for a single project, across all branches."
},
"trends": {
"type": "object",
"properties": {
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"total_duration_secs": {
"type": "number",
"format": "float",
"description": "Trend value for total duration."
},
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
}
},
"required": [
"total_credits_used",
"total_duration_secs",
"total_runs",
"success_rate"
],
"description": "Trends for a single project, across all branches."
}
},
"required": [
"project_name",
"metrics",
"trends"
]
},
"description": "Metrics for a single project, across all branches"
},
"all_projects": {
"type": "array",
"items": {
"type": "string"
},
"x-nullable": true,
"description": "A list of all the project names in the organization."
}
},
"required": [
"org_data",
"org_project_data",
"all_projects"
],
"description": "Summary metrics with trends for the entire org, and for each project."
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "org-slug",
"description": "Org slug in the form `vcs-slug/org-name`. The `/` characters may be URL-escaped.",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public"
},
{
"in": "query",
"name": "reporting-window",
"description": "The time window used to calculate summary metrics. If not provided, defaults to last-90-days",
"schema": {
"type": "string",
"enum": [
"last-7-days",
"last-90-days",
"last-24-hours",
"last-30-days",
"last-60-days"
]
},
"required": false,
"example": "last-90-days"
},
{
"in": "query",
"name": "project-names",
"description": "List of project names.",
"schema": {
"type": "object"
},
"required": false,
"example": "For a single project: ?project-names=some-project or for multiple projects: ?project-names=some-project1&project-names=some-project2"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/summary',\n qs: {'reporting-window': 'SOME_STRING_VALUE', 'project-names': 'SOME_OBJECT_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/summary?reporting-window=SOME_STRING_VALUE&project-names=SOME_OBJECT_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/summary?reporting-window=SOME_STRING_VALUE&project-names=SOME_OBJECT_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/summary?reporting-window=SOME_STRING_VALUE&project-names=SOME_OBJECT_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/branches": {
"get": {
"summary": "Get all branches for a project",
"description": "Get a list of all branches for a specified project. The list will only contain branches currently available within Insights. The maximum number of branches returned by this endpoint is 5,000.",
"tags": [
"Insights"
],
"operationId": "getAllInsightsBranches",
"responses": {
"200": {
"description": "A list of branches for a project",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"org_id": {
"description": "The unique ID of the organization"
},
"project_id": {
"description": "The unique ID of the project"
},
"branches": {
"type": "array",
"items": {
"type": "string",
"description": "The VCS branch of a workflow's trigger.",
"example": "main"
},
"description": "A list of all the branches for a given project."
}
},
"required": [
"org_id",
"project_id",
"branches"
],
"description": "Project branches response."
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "workflow-name",
"description": "The name of a workflow. If not passed we will scope the API call to the project.",
"schema": {
"type": "string"
},
"required": false,
"example": "build-and-test"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/branches',\n qs: {'workflow-name': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/branches?workflow-name=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/branches?workflow-name=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/branches?workflow-name=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/flaky-tests": {
"get": {
"summary": "Get flaky tests for a project",
"description": "Get a list of flaky tests for a given project. Flaky tests are branch agnostic.\n A flaky test is a test that passed and failed in the same commit.",
"tags": [
"Insights"
],
"operationId": "getFlakyTests",
"responses": {
"200": {
"description": "A list of flaky tests for a project",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"flaky-tests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"time-wasted": {
"allOf": [
{
"type": "integer",
"format": "int64"
},
{
"type": "integer",
"format": "int64",
"minimum": 0
}
]
},
"workflow-created-at": {
"type": "string",
"description": "The date and time when workflow was created."
},
"workflow-id": {
"description": "The ID of the workflow associated with the provided test counts"
},
"classname": {
"type": "string",
"x-nullable": true,
"description": "The class the test belongs to."
},
"pipeline-number": {
"allOf": [
{
"type": "integer",
"format": "int64"
},
{
"type": "integer",
"format": "int64",
"minimum": 0
}
],
"description": "The number of the pipeline."
},
"workflow-name": {
"type": "string",
"description": "The name of the workflow."
},
"test-name": {
"type": "string",
"description": "The name of the test."
},
"job-name": {
"type": "string",
"description": "The name of the job."
},
"job-number": {
"allOf": [
{
"type": "integer",
"format": "int64"
},
{
"type": "integer",
"format": "int64",
"minimum": 0
}
],
"description": "The number of the job."
},
"times-flaked": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of times the test flaked."
},
"source": {
"type": "string",
"x-nullable": true,
"description": "The source of the test."
},
"file": {
"type": "string",
"x-nullable": true,
"description": "The file the test belongs to."
}
},
"required": [
"workflow-created-at",
"classname",
"job-number",
"times-flaked",
"source",
"pipeline-number",
"file",
"workflow-name",
"job-name",
"workflow-id",
"test-name"
]
},
"description": "A list of all instances of flakes. Note that a test is no longer considered flaky after 2 weeks have passed without a flake. Each flake resets this timer."
},
"total-flaky-tests": {
"type": "number",
"format": "double",
"description": "A count of unique tests that have failed. If your project has N tests that have flaked multiple times each, this will be equal to N.",
"example": 5
}
},
"required": [
"flaky-tests",
"total-flaky-tests"
],
"description": "Flaky tests response"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/flaky-tests',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/flaky-tests\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/flaky-tests\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/flaky-tests \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/workflows": {
"get": {
"summary": "Get summary metrics for a project's workflows",
"description": "Get summary metrics for a project's workflows. Workflow runs going back at most 90 days are included in the aggregation window. Metrics are refreshed daily, and thus may not include executions from the last 24 hours. Please note that Insights is not a financial reporting tool and should not be used for precise credit reporting. Credit reporting from Insights does not use the same source of truth as the billing information that is found in the Plan Overview page in the CircleCI UI, nor does the underlying data have the same data accuracy guarantees as the billing information in the CircleCI UI. This may lead to discrepancies between credits reported from Insights and the billing information in the Plan Overview page of the CircleCI UI. For precise credit reporting, always use the Plan Overview page in the CircleCI UI.",
"tags": [
"Insights"
],
"operationId": "getProjectWorkflowMetrics",
"responses": {
"200": {
"description": "A paginated list of summary metrics by workflow",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"successful_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of successful runs."
},
"mttr": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The mean time to recovery (mean time between failures and their next success) in seconds."
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The total credits consumed by the workflow in the aggregation window. Note that Insights is not a real time financial reporting tool and should not be used for credit reporting."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of failed runs."
},
"success_rate": {
"type": "number",
"format": "float"
},
"duration_metrics": {
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The minimum duration, in seconds, among a group of runs."
},
"mean": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The mean duration, in seconds, among a group of runs."
},
"median": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The median duration, in seconds, among a group of runs."
},
"p95": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of runs."
},
"max": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The max duration, in seconds, among a group of runs."
},
"standard_deviation": {
"type": "number",
"format": "float",
"x-nullable": true,
"description": "The standard deviation, in seconds, among a group of runs."
}
},
"required": [
"min",
"mean",
"median",
"p95",
"max",
"standard_deviation"
],
"description": "Metrics relating to the duration of runs for a workflow."
},
"total_recoveries": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The number of recovered workflow executions per day."
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
}
},
"required": [
"total_runs",
"successful_runs",
"mttr",
"total_credits_used",
"failed_runs",
"success_rate",
"duration_metrics",
"total_recoveries",
"throughput"
],
"description": "Metrics relating to a workflow's runs."
},
"window_start": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the first build within the requested reporting window."
},
"window_end": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the last build within the requested reporting window."
},
"project_id": {
"description": "The unique ID of the project"
}
},
"required": [
"name",
"metrics",
"window_start",
"window_end",
"project_id"
]
},
"description": "Workflow summary metrics."
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "Paginated workflow summary metrics."
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
},
{
"in": "query",
"name": "all-branches",
"description": "Whether to retrieve data for all branches combined. Use either this parameter OR the branch name parameter.",
"schema": {
"type": "boolean"
},
"required": false
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "reporting-window",
"description": "The time window used to calculate summary metrics. If not provided, defaults to last-90-days",
"schema": {
"type": "string",
"enum": [
"last-7-days",
"last-90-days",
"last-24-hours",
"last-30-days",
"last-60-days"
]
},
"required": false,
"example": "last-90-days"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows',\n qs: {\n 'page-token': 'SOME_STRING_VALUE',\n 'all-branches': 'SOME_BOOLEAN_VALUE',\n branch: 'SOME_STRING_VALUE',\n 'reporting-window': 'SOME_STRING_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/workflows/{workflow-name}": {
"get": {
"summary": "Get recent runs of a workflow",
"description": "Get recent runs of a workflow. Runs going back at most 90 days are returned. Please note that Insights is not a financial reporting tool and should not be used for precise credit reporting. Credit reporting from Insights does not use the same source of truth as the billing information that is found in the Plan Overview page in the CircleCI UI, nor does the underlying data have the same data accuracy guarantees as the billing information in the CircleCI UI. This may lead to discrepancies between credits reported from Insights and the billing information in the Plan Overview page of the CircleCI UI. For precise credit reporting, always use the Plan Overview page in the CircleCI UI.",
"tags": [
"Insights"
],
"operationId": "getProjectWorkflowRuns",
"responses": {
"200": {
"description": "A paginated list of recent workflow runs",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the workflow."
},
"branch": {
"type": "string",
"description": "The VCS branch of a Workflow's trigger.",
"example": "main"
},
"duration": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The duration in seconds of a run."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the workflow was created."
},
"stopped_at": {
"type": "string",
"format": "date-time",
"x-nullable": true,
"description": "The date and time the workflow stopped."
},
"credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of credits used during execution. Note that Insights is not a real time financial reporting tool and should not be used for credit reporting."
},
"status": {
"enum": [
"success",
"failed",
"error",
"canceled",
"unauthorized"
],
"type": "string",
"x-nullable": true,
"description": "Workflow status."
},
"is_approval": {
"type": "boolean",
"description": "Describes if the job is an approval job or not. Approval jobs are intermediary jobs that are created to pause the workflow until approved.",
"example": false
}
},
"required": [
"id",
"branch",
"duration",
"created_at",
"stopped_at",
"credits_used",
"status",
"is_approval"
]
},
"description": "Recent workflow runs."
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "Paginated recent workflow runs."
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "workflow-name",
"description": "The name of the workflow.",
"schema": {
"type": "string"
},
"required": true,
"example": "build-and-test"
},
{
"in": "query",
"name": "all-branches",
"description": "Whether to retrieve data for all branches combined. Use either this parameter OR the branch name parameter.",
"schema": {
"type": "boolean"
},
"required": false
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
},
{
"in": "query",
"name": "start-date",
"description": "Include only executions that started at or after this date. This must be specified if an end-date is provided.",
"schema": {
"type": "string",
"format": "date-time"
},
"required": false,
"example": "2020-08-21T13:26:29Z"
},
{
"in": "query",
"name": "end-date",
"description": "Include only executions that started before this date. This date can be at most 90 days after the start-date.",
"schema": {
"type": "string",
"format": "date-time"
},
"required": false,
"example": "2020-09-04T13:26:29Z"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test',\n qs: {\n 'all-branches': 'SOME_BOOLEAN_VALUE',\n branch: 'SOME_STRING_VALUE',\n 'page-token': 'SOME_STRING_VALUE',\n 'start-date': 'SOME_STRING_VALUE',\n 'end-date': 'SOME_STRING_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/workflows/{workflow-name}/jobs": {
"get": {
"summary": "Get summary metrics for a project workflow's jobs.",
"description": "Get summary metrics for a project workflow's jobs. Job runs going back at most 90 days are included in the aggregation window. Metrics are refreshed daily, and thus may not include executions from the last 24 hours. Please note that Insights is not a financial reporting tool and should not be used for precise credit reporting. Credit reporting from Insights does not use the same source of truth as the billing information that is found in the Plan Overview page in the CircleCI UI, nor does the underlying data have the same data accuracy guarantees as the billing information in the CircleCI UI. This may lead to discrepancies between credits reported from Insights and the billing information in the Plan Overview page of the CircleCI UI. For precise credit reporting, always use the Plan Overview page in the CircleCI UI.",
"tags": [
"Insights"
],
"operationId": "getProjectWorkflowJobMetrics",
"responses": {
"200": {
"description": "A paginated list of summary metrics by workflow job.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the job."
},
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of failed runs."
},
"successful_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of successful runs."
},
"duration_metrics": {
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The minimum duration, in seconds, among a group of runs."
},
"mean": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The mean duration, in seconds, among a group of runs."
},
"median": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The median duration, in seconds, among a group of runs."
},
"p95": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of runs."
},
"max": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The max duration, in seconds, among a group of runs."
},
"standard_deviation": {
"type": "number",
"format": "float",
"x-nullable": true,
"description": "The standard deviation, in seconds, among a group of runs."
}
},
"required": [
"min",
"mean",
"median",
"p95",
"max",
"standard_deviation"
],
"description": "Metrics relating to the duration of runs for a workflow job."
},
"success_rate": {
"type": "number",
"format": "float"
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total credits consumed by the job in the aggregation window. Note that Insights is not a real time financial reporting tool and should not be used for credit reporting."
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
}
},
"required": [
"total_runs",
"failed_runs",
"successful_runs",
"duration_metrics",
"success_rate",
"total_credits_used",
"throughput"
],
"description": "Metrics relating to a workflow job's runs."
},
"window_start": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the first build within the requested reporting window."
},
"window_end": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the last build within the requested reporting window."
}
},
"required": [
"name",
"metrics",
"window_start",
"window_end"
]
},
"description": "Job summary metrics."
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "Paginated workflow job summary metrics."
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "workflow-name",
"description": "The name of the workflow.",
"schema": {
"type": "string"
},
"required": true,
"example": "build-and-test"
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
},
{
"in": "query",
"name": "all-branches",
"description": "Whether to retrieve data for all branches combined. Use either this parameter OR the branch name parameter.",
"schema": {
"type": "boolean"
},
"required": false
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "reporting-window",
"description": "The time window used to calculate summary metrics. If not provided, defaults to last-90-days",
"schema": {
"type": "string",
"enum": [
"last-7-days",
"last-90-days",
"last-24-hours",
"last-30-days",
"last-60-days"
]
},
"required": false,
"example": "last-90-days"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs',\n qs: {\n 'page-token': 'SOME_STRING_VALUE',\n 'all-branches': 'SOME_BOOLEAN_VALUE',\n branch: 'SOME_STRING_VALUE',\n 'reporting-window': 'SOME_STRING_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?page-token=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE&reporting-window=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/workflows/{workflow-name}/summary": {
"get": {
"summary": "Get metrics and trends for workflows",
"description": "Get the metrics and trends for a particular workflow on a single branch or all branches",
"tags": [
"Insights"
],
"operationId": "getWorkflowSummary",
"responses": {
"200": {
"description": "Metrics and trends for a workflow",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"metrics": {
"type": "object",
"properties": {
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of runs, including runs that are still on-hold or running."
},
"successful_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of successful runs."
},
"mttr": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The mean time to recovery (mean time between failures and their next success) in seconds."
},
"total_credits_used": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The total credits consumed by the workflow in the aggregation window. Note that Insights is not a real time financial reporting tool and should not be used for credit reporting."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of failed runs."
},
"success_rate": {
"type": "number",
"format": "float"
},
"completed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The number of runs that ran to completion within the aggregation window"
},
"window_start": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the first build within the requested reporting window."
},
"duration_metrics": {
"type": "object",
"properties": {
"min": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The minimum duration, in seconds, among a group of runs."
},
"mean": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The mean duration, in seconds, among a group of runs."
},
"median": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The median duration, in seconds, among a group of runs."
},
"p95": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of runs."
},
"max": {
"type": "integer",
"format": "int64",
"minimum": 0,
"x-nullable": true,
"description": "The max duration, in seconds, among a group of runs."
},
"standard_deviation": {
"type": "number",
"format": "float",
"x-nullable": true,
"description": "The standard deviation, in seconds, among a group of runs."
}
},
"required": [
"min",
"mean",
"median",
"p95",
"max",
"standard_deviation"
],
"description": "Metrics relating to the duration of runs for a workflow."
},
"window_end": {
"type": "string",
"format": "date-time",
"description": "The timestamp of the last build within the requested reporting window."
},
"throughput": {
"type": "number",
"format": "float",
"description": "The average number of runs per day."
}
},
"required": [
"total_runs",
"successful_runs",
"mttr",
"total_credits_used",
"failed_runs",
"success_rate",
"window_start",
"duration_metrics",
"window_end",
"throughput",
"completed_runs"
],
"description": "Metrics aggregated across a workflow for a given time window."
},
"trends": {
"type": "object",
"properties": {
"total_runs": {
"type": "number",
"format": "float",
"description": "The trend value for total number of runs."
},
"failed_runs": {
"type": "number",
"format": "float",
"description": "The trend value for number of failed runs."
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The trend value for the success rate."
},
"p95_duration_secs": {
"type": "number",
"format": "float",
"description": "Trend value for the 95th percentile duration for a workflow for a given time window."
},
"median_duration_secs": {
"type": "number",
"format": "float",
"description": "Trend value for the 50th percentile duration for a workflow for a given time window."
},
"total_credits_used": {
"type": "number",
"format": "float",
"description": "The trend value for total credits consumed."
},
"mttr": {
"type": "number",
"format": "float",
"description": "trend for mean time to recovery (mean time between failures and their next success)."
},
"throughput": {
"type": "number",
"format": "float",
"description": "Trend value for the average number of runs per day."
}
},
"required": [
"total_runs",
"failed_runs",
"success_rate",
"p95_duration_secs",
"median_duration_secs",
"total_credits_used",
"mttr",
"throughput"
],
"description": "Trends for aggregated metrics across a workflow for a given time window."
},
"workflow_names": {
"type": "array",
"items": {
"type": "string"
},
"description": "A list of all the workflow names for a given project."
}
},
"required": [
"metrics",
"trends",
"workflow_names"
],
"description": "Workflow level aggregated metrics and trends response"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "workflow-name",
"description": "The name of the workflow.",
"schema": {
"type": "string"
},
"required": true,
"example": "build-and-test"
},
{
"in": "query",
"name": "all-branches",
"description": "Whether to retrieve data for all branches combined. Use either this parameter OR the branch name parameter.",
"schema": {
"type": "boolean"
},
"required": false
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/summary',\n qs: {'all-branches': 'SOME_BOOLEAN_VALUE', branch: 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branch=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/insights/{project-slug}/workflows/{workflow-name}/test-metrics": {
"get": {
"summary": "Get test metrics for a project's workflows",
"description": "Get test metrics for a project's workflows. Currently tests metrics are calculated based on 10 most recent workflow runs.",
"tags": [
"Insights"
],
"operationId": "getProjectWorkflowTestMetrics",
"responses": {
"200": {
"description": "A list of test metrics by workflow",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"average_test_count": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The average number of tests executed per run"
},
"most_failed_tests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"p95_duration": {
"type": "number",
"format": "double",
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of test runs."
},
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of times the test was run."
},
"classname": {
"type": "string",
"x-nullable": true,
"description": "The class the test belongs to."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of times the test failed"
},
"flaky": {
"type": "boolean",
"description": "Whether the test is flaky."
},
"source": {
"type": "string",
"x-nullable": true,
"description": "The source of the test."
},
"file": {
"type": "string",
"x-nullable": true,
"description": "The file the test belongs to."
},
"job_name": {
"type": "string",
"description": "The name of the job."
},
"test_name": {
"type": "string",
"description": "The name of the test."
}
},
"required": [
"failed_runs",
"job_name",
"p95_duration",
"test_name",
"file",
"source",
"classname",
"total_runs",
"flaky"
]
},
"description": "Metrics for the most frequently failing tests"
},
"most_failed_tests_extra": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the same success rate being omitted from most_failed_tests"
},
"slowest_tests": {
"type": "array",
"items": {
"type": "object",
"properties": {
"p95_duration": {
"type": "number",
"format": "double",
"x-nullable": true,
"description": "The 95th percentile duration, in seconds, among a group of test runs."
},
"total_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of times the test was run."
},
"classname": {
"type": "string",
"x-nullable": true,
"description": "The class the test belongs to."
},
"failed_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of times the test failed"
},
"flaky": {
"type": "boolean",
"description": "Whether the test is flaky."
},
"source": {
"type": "string",
"x-nullable": true,
"description": "The source of the test."
},
"file": {
"type": "string",
"x-nullable": true,
"description": "The file the test belongs to."
},
"job_name": {
"type": "string",
"description": "The name of the job."
},
"test_name": {
"type": "string",
"description": "The name of the test."
}
},
"required": [
"failed_runs",
"job_name",
"p95_duration",
"test_name",
"file",
"source",
"classname",
"total_runs",
"flaky"
]
},
"description": "Metrics for the slowest running tests"
},
"slowest_tests_extra": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the same duration rate being omitted from slowest_tests"
},
"total_test_runs": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of test runs"
},
"test_runs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"pipeline_number": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of the pipeline associated with the provided test counts"
},
"workflow_id": {
"description": "The ID of the workflow associated with the provided test counts"
},
"success_rate": {
"type": "number",
"format": "float",
"description": "The success rate calculated from test counts"
},
"test_counts": {
"type": "object",
"properties": {
"error": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the error status"
},
"failure": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the failure status"
},
"skipped": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the skipped status"
},
"success": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The number of tests with the success status"
},
"total": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The total number of tests"
}
},
"required": [
"error",
"failure",
"skipped",
"success",
"total"
],
"description": "Test counts for a given pipeline number"
}
},
"required": [
"pipeline_number",
"workflow_id",
"success_rate",
"test_counts"
]
},
"description": "Test counts grouped by pipeline number and workflow id"
}
},
"required": [
"average_test_count",
"most_failed_tests",
"most_failed_tests_extra",
"slowest_tests",
"slowest_tests_extra",
"total_test_runs",
"test_runs"
],
"description": "Project level test metrics response"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "workflow-name",
"description": "The name of the workflow.",
"schema": {
"type": "string"
},
"required": true,
"example": "build-and-test"
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch. If not passed we will scope the API call to the default branch.",
"schema": {
"type": "string"
},
"required": false
},
{
"in": "query",
"name": "all-branches",
"description": "Whether to retrieve data for all branches combined. Use either this parameter OR the branch name parameter.",
"schema": {
"type": "boolean"
},
"required": false
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/test-metrics',\n qs: {branch: 'SOME_STRING_VALUE', 'all-branches': 'SOME_BOOLEAN_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/test-metrics?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/test-metrics?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/test-metrics?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/me": {
"get": {
"summary": "User Information",
"description": "Provides information about the user that is currently signed in.",
"tags": [
"User"
],
"operationId": "getCurrentUser",
"responses": {
"200": {
"description": "User login information.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/me',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/me\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/me\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/me \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/me/collaborations": {
"get": {
"summary": "Collaborations",
"description": "Provides the set of organizations of which a user is a member or a collaborator.\n\nThe set of organizations that a user can collaborate on is composed of:\n\n* Organizations that the current user belongs to across VCS types (e.g. BitBucket, GitHub)\n* The parent organization of repository that the user can collaborate on, but is not necessarily a member of\n* The organization of the current user's account",
"tags": [
"User"
],
"operationId": "getCollaborations",
"responses": {
"200": {
"description": "Collaborations",
"content": {
"application/json": {
"schema": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"x-nullable": true,
"description": "The UUID of the organization"
},
"vcs-type": {
"type": "string",
"description": "The VCS provider"
},
"name": {
"type": "string",
"description": "The name of the organization"
},
"avatar_url": {
"type": "string",
"description": "URL to the user's avatar on the VCS"
},
"slug": {
"type": "string",
"description": "The slug of the organization"
}
},
"required": [
"id",
"vcs-type",
"name",
"avatar_url",
"slug"
],
"title": "Collaboration"
}
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/me/collaborations',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/me/collaborations\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/me/collaborations\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/me/collaborations \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/pipeline": {
"get": {
"summary": "Get a list of pipelines",
"description": "Returns all pipelines for the most recently built projects (max 250) you follow in an organization.",
"tags": [
"Pipeline"
],
"operationId": "listPipelines",
"responses": {
"200": {
"description": "A sequence of pipelines.",
"links": {
"NextPipelinePage": {
"operationId": "listPipelines",
"parameters": {
"page-token": "$response.body#/next_page_token"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"config",
"config-fetch",
"timeout",
"permission",
"other",
"trigger-rule",
"plan"
],
"type": "string",
"description": "The type of error."
},
"message": {
"type": "string",
"description": "A human-readable error message."
}
},
"required": [
"type",
"message"
],
"description": "An error with a type and message."
},
"description": "A sequence of errors that have occurred within the pipeline."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"trigger_parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "boolean"
},
{
"type": "object"
}
]
}
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"trigger": {
"type": "object",
"properties": {
"type": {
"enum": [
"scheduled_pipeline",
"explicit",
"api",
"webhook"
],
"type": "string",
"description": "The type of trigger."
},
"received_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the trigger was received."
},
"actor": {
"type": "object",
"properties": {
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"avatar_url": {
"type": "string",
"x-nullable": true,
"description": "URL to the user's avatar on the VCS"
}
},
"required": [
"login",
"avatar_url"
],
"description": "The user who triggered the Pipeline."
}
},
"required": [
"type",
"received_at",
"actor"
],
"description": "A summary of the trigger."
},
"vcs": {
"type": "object",
"properties": {
"provider_name": {
"type": "string",
"description": "Name of the VCS provider (e.g. GitHub, Bitbucket).",
"example": "GitHub"
},
"target_repository_url": {
"type": "string",
"description": "URL for the repository the trigger targets (i.e. the repository where the PR will be merged). For fork-PR pipelines, this is the URL to the parent repo. For other pipelines, the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"review_id": {
"type": "string",
"description": "The code review id.",
"example": "123"
},
"review_url": {
"type": "string",
"description": "The code review URL.",
"example": "https://github.com/CircleCI-Public/api-preview-docs/pull/123"
},
"revision": {
"type": "string",
"description": "The code revision the pipeline ran.",
"example": "f454a02b5d10fcccfd7d9dd7608a76d6493a98b4"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"commit": {
"type": "object",
"properties": {
"subject": {
"type": "string",
"x-nullable": true,
"description": "The subject of the commit message."
},
"body": {
"type": "string",
"x-nullable": true,
"description": "The body of the commit message."
}
},
"required": [
"subject",
"body"
],
"description": "The latest commit in the pipeline."
},
"origin_repository_url": {
"type": "string",
"description": "URL for the repository where the trigger originated. For fork-PR pipelines, this is the URL to the fork. For other pipelines the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"provider_name",
"origin_repository_url",
"target_repository_url",
"revision"
],
"description": "VCS information for the pipeline."
}
},
"required": [
"id",
"number",
"project_slug",
"created_at",
"errors",
"state",
"trigger"
],
"description": "A pipeline response.",
"title": "Pipeline"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "List of pipelines",
"title": "PipelineListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "query",
"name": "org-slug",
"description": "Org slug in the form `vcs-slug/org-name`. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug` and replace the `org-name` with the organization ID (found in Organization Settings).",
"schema": {
"type": "string"
},
"required": false,
"example": "gh/CircleCI-Public"
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
},
{
"in": "query",
"name": "mine",
"description": "Only include entries created by your user.",
"schema": {
"type": "boolean"
},
"required": false
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline',\n qs: {\n 'org-slug': 'SOME_STRING_VALUE',\n 'page-token': 'SOME_STRING_VALUE',\n mine: 'SOME_BOOLEAN_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/pipeline?org-slug=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&mine=SOME_BOOLEAN_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/pipeline?org-slug=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&mine=SOME_BOOLEAN_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/pipeline?org-slug=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&mine=SOME_BOOLEAN_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/pipeline/continue": {
"post": {
"summary": "Continue a pipeline",
"description": "Continue a pipeline from the setup phase. For information on using pipeline parameters with dynamic configuration, see the [Pipeline values and parameters](https://circleci.com/docs/pipeline-variables/#pipeline-parameters-and-dynamic-configuration) docs.",
"tags": [
"Pipeline"
],
"operationId": "continuePipeline",
"responses": {
"200": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"continuation-key": {
"type": "string",
"description": "A pipeline continuation key.",
"title": "PipelineContinuationKey"
},
"configuration": {
"type": "string",
"description": "A configuration string for the pipeline."
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "An object containing pipeline parameters and their values. Pipeline parameters have the following size limits: 100 max entries, 128 maximum key length, 512 maximum value length.",
"example": {
"deploy_prod": true
}
}
},
"required": [
"continuation-key",
"configuration"
]
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/pipeline/continue',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n 'continuation-key': 'string',\n configuration: 'string',\n parameters: {deploy_prod: true}\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"continuation-key\\\":\\\"string\\\",\\\"configuration\\\":\\\"string\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/pipeline/continue\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/pipeline/continue\"\n\n\tpayload := strings.NewReader(\"{\\\"continuation-key\\\":\\\"string\\\",\\\"configuration\\\":\\\"string\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/pipeline/continue \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"continuation-key\":\"string\",\"configuration\":\"string\",\"parameters\":{\"deploy_prod\":true}}'"
}
]
}
},
"/pipeline/{pipeline-id}": {
"get": {
"summary": "Get a pipeline by ID",
"description": "Returns a pipeline by the pipeline ID.",
"tags": [
"Pipeline"
],
"operationId": "getPipelineById",
"responses": {
"200": {
"description": "A pipeline object.",
"links": {
"ProjectFromPipeline": {
"operationId": "getProjectBySlug",
"parameters": {
"project_slug": "$response.body#/project_slug"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"config",
"config-fetch",
"timeout",
"permission",
"other",
"trigger-rule",
"plan"
],
"type": "string",
"description": "The type of error."
},
"message": {
"type": "string",
"description": "A human-readable error message."
}
},
"required": [
"type",
"message"
],
"description": "An error with a type and message."
},
"description": "A sequence of errors that have occurred within the pipeline."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"trigger_parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "boolean"
},
{
"type": "object"
}
]
}
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"trigger": {
"type": "object",
"properties": {
"type": {
"enum": [
"scheduled_pipeline",
"explicit",
"api",
"webhook"
],
"type": "string",
"description": "The type of trigger."
},
"received_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the trigger was received."
},
"actor": {
"type": "object",
"properties": {
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"avatar_url": {
"type": "string",
"x-nullable": true,
"description": "URL to the user's avatar on the VCS"
}
},
"required": [
"login",
"avatar_url"
],
"description": "The user who triggered the Pipeline."
}
},
"required": [
"type",
"received_at",
"actor"
],
"description": "A summary of the trigger."
},
"vcs": {
"type": "object",
"properties": {
"provider_name": {
"type": "string",
"description": "Name of the VCS provider (e.g. GitHub, Bitbucket).",
"example": "GitHub"
},
"target_repository_url": {
"type": "string",
"description": "URL for the repository the trigger targets (i.e. the repository where the PR will be merged). For fork-PR pipelines, this is the URL to the parent repo. For other pipelines, the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"review_id": {
"type": "string",
"description": "The code review id.",
"example": "123"
},
"review_url": {
"type": "string",
"description": "The code review URL.",
"example": "https://github.com/CircleCI-Public/api-preview-docs/pull/123"
},
"revision": {
"type": "string",
"description": "The code revision the pipeline ran.",
"example": "f454a02b5d10fcccfd7d9dd7608a76d6493a98b4"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"commit": {
"type": "object",
"properties": {
"subject": {
"type": "string",
"x-nullable": true,
"description": "The subject of the commit message."
},
"body": {
"type": "string",
"x-nullable": true,
"description": "The body of the commit message."
}
},
"required": [
"subject",
"body"
],
"description": "The latest commit in the pipeline."
},
"origin_repository_url": {
"type": "string",
"description": "URL for the repository where the trigger originated. For fork-PR pipelines, this is the URL to the fork. For other pipelines the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"provider_name",
"origin_repository_url",
"target_repository_url",
"revision"
],
"description": "VCS information for the pipeline."
}
},
"required": [
"id",
"number",
"project_slug",
"created_at",
"errors",
"state",
"trigger"
],
"description": "A pipeline response.",
"title": "Pipeline"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "pipeline-id",
"description": "The unique ID of the pipeline.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/pipeline/{pipeline-id}/config": {
"get": {
"summary": "Get a pipeline's configuration",
"description": "Returns a pipeline's configuration by ID.",
"tags": [
"Pipeline"
],
"operationId": "getPipelineConfigById",
"responses": {
"200": {
"description": "The configuration strings for the pipeline.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"source": {
"type": "string",
"description": "The source configuration for the pipeline, before any config compilation has been performed. If there is no config, then this field will be empty."
},
"compiled": {
"type": "string",
"description": "The compiled configuration for the pipeline, after all orb expansion has been performed. If there were errors processing the pipeline's configuration, then this field may be empty."
},
"setup-config": {
"type": "string",
"description": "The setup configuration for the pipeline used for Setup Workflows. If there were errors processing the pipeline's configuration or if setup workflows are not enabled, then this field should not exist"
},
"compiled-setup-config": {
"type": "string",
"description": "The compiled setup configuration for the pipeline, after all orb expansion has been performed. If there were errors processing the pipeline's setup workflows, then this field may be empty."
}
},
"required": [
"source",
"compiled"
],
"description": "The configuration strings for the pipeline.",
"title": "PipelineConfig"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "pipeline-id",
"description": "The unique ID of the pipeline.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/config',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/config\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/config\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/config \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/pipeline/{pipeline-id}/workflow": {
"get": {
"summary": "Get a pipeline's workflows",
"description": "Returns a paginated list of workflows by pipeline ID.",
"tags": [
"Pipeline"
],
"operationId": "listWorkflowsByPipelineId",
"responses": {
"200": {
"description": "A paginated list of workflow objects.",
"links": {
"NextPipelineWorkflowsPage": {
"operationId": "listWorkflowsByPipelineId",
"parameters": {
"pipeline-id": "$request.path.pipeline-id",
"page-token": "$response.body#/next_page_token"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"pipeline_id": {
"type": "string",
"format": "uuid",
"description": "The ID of the pipeline this workflow belongs to.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"canceled_by": {
"type": "string",
"format": "uuid"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the workflow."
},
"name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline this workflow belongs to.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"errored_by": {
"type": "string",
"format": "uuid"
},
"tag": {
"enum": [
"setup"
],
"type": "string",
"x-nullable": true,
"description": "Tag used for the workflow",
"example": "setup"
},
"status": {
"enum": [
"success",
"running",
"not_run",
"failed",
"error",
"failing",
"on_hold",
"canceled",
"unauthorized"
],
"type": "string",
"description": "The current status of the workflow."
},
"started_by": {
"type": "string",
"format": "uuid"
},
"pipeline_number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline this workflow belongs to.",
"example": "25"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the workflow was created."
},
"stopped_at": {
"type": "string",
"format": "date-time",
"x-nullable": true,
"description": "The date and time the workflow stopped."
}
},
"required": [
"id",
"name",
"status",
"created_at",
"stopped_at",
"pipeline_id",
"pipeline_number",
"project_slug",
"started_by"
],
"description": "A workflow",
"title": "Workflow"
},
"description": "A list of workflows.",
"title": "Workflow list"
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "A list of workflows and associated pagination token.",
"title": "WorkflowListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "pipeline-id",
"description": "The unique ID of the pipeline.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/workflow',\n qs: {'page-token': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/workflow?page-token=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/workflow?page-token=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/pipeline/5034460f-c7c4-4c43-9457-de07e2029e7b/workflow?page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}": {
"get": {
"summary": "Get a project",
"description": "Retrieves a project by project slug.",
"tags": [
"Project"
],
"operationId": "getProjectBySlug",
"responses": {
"200": {
"description": "A project object",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"slug": {
"type": "string",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"name": {
"type": "string",
"description": "The name of the project",
"example": "api-preview-docs"
},
"id": {
"type": "string",
"format": "uuid"
},
"organization_name": {
"type": "string",
"description": "The name of the organization the project belongs to",
"example": "CircleCI-Public"
},
"organization_slug": {
"type": "string",
"description": "The slug of the organization the project belongs to",
"example": "CircleCI-Public"
},
"organization_id": {
"type": "string",
"format": "uuid",
"description": "The id of the organization the project belongs to",
"example": "CircleCI-Public"
},
"vcs_info": {
"type": "object",
"properties": {
"vcs_url": {
"type": "string",
"description": "URL to the repository hosting the project's code",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"provider": {
"enum": [
"Bitbucket",
"CircleCI",
"GitHub"
],
"type": "string",
"description": "The VCS provider"
},
"default_branch": {
"type": "string",
"example": "master"
}
},
"required": [
"vcs_url",
"provider",
"default_branch"
],
"description": "Information about the VCS that hosts the project source code."
}
},
"required": [
"slug",
"name",
"id",
"organization_name",
"organization_slug",
"organization_id",
"vcs_info"
],
"description": "NOTE: The definition of Project is subject to change.",
"title": "Project"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/checkout-key": {
"post": {
"summary": "Create a new checkout key",
"description": "Not available to projects that use GitLab or GitHub App. Creates a new checkout key. This API request is only usable with a user API token.\n Please ensure that you have authorized your account with GitHub before creating user keys.\n This is necessary to give CircleCI the permission to create a user key associated with\n your GitHub user account. You can find this page by visiting Project Settings > Checkout SSH Keys",
"tags": [
"Project"
],
"operationId": "createCheckoutKey",
"responses": {
"201": {
"description": "The checkout key.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"public-key": {
"type": "string",
"description": "A public SSH key.",
"example": "ssh-rsa ..."
},
"type": {
"enum": [
"deploy-key",
"github-user-key"
],
"type": "string",
"description": "The type of checkout key. This may be either `deploy-key` or `github-user-key`.",
"title": "CheckoutKeyType",
"example": "deploy-key"
},
"fingerprint": {
"type": "string",
"description": "An SSH key fingerprint.",
"example": "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
},
"preferred": {
"type": "boolean",
"description": "A boolean value that indicates if this key is preferred.",
"example": true
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the checkout key was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"public-key",
"type",
"fingerprint",
"preferred",
"created-at"
],
"description": "A checkout key",
"title": "CheckoutKey"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"type": {
"enum": [
"user-key",
"deploy-key"
],
"type": "string",
"description": "The type of checkout key to create. This may be either `deploy-key` or `user-key`.",
"title": "CheckoutKeyInputType",
"example": "deploy-key"
}
},
"required": [
"type"
],
"title": "CheckoutKeyInput"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {type: 'deploy-key'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"type\\\":\\\"deploy-key\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key\"\n\n\tpayload := strings.NewReader(\"{\\\"type\\\":\\\"deploy-key\\\"}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"type\":\"deploy-key\"}'"
}
]
},
"get": {
"summary": "Get all checkout keys",
"description": "Returns a sequence of checkout keys for `:project`.",
"tags": [
"Project"
],
"operationId": "listCheckoutKeys",
"responses": {
"200": {
"description": "A sequence of checkout keys.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"public-key": {
"type": "string",
"description": "A public SSH key.",
"example": "ssh-rsa ..."
},
"type": {
"enum": [
"deploy-key",
"github-user-key"
],
"type": "string",
"description": "The type of checkout key. This may be either `deploy-key` or `github-user-key`.",
"title": "CheckoutKeyType",
"example": "deploy-key"
},
"fingerprint": {
"type": "string",
"description": "An SSH key fingerprint.",
"example": "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
},
"preferred": {
"type": "boolean",
"description": "A boolean value that indicates if this key is preferred.",
"example": true
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the checkout key was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"public-key",
"type",
"fingerprint",
"preferred",
"created-at"
],
"description": "A checkout key",
"title": "CheckoutKey"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"title": "CheckoutKeyListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "digest",
"description": "The fingerprint digest type to return. This may be either `md5` or `sha256`. If not passed, defaults to `md5`.",
"schema": {
"type": "string",
"enum": [
"sha256",
"md5"
]
},
"required": false
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key',\n qs: {digest: 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key?digest=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key?digest=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key?digest=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/checkout-key/{fingerprint}": {
"delete": {
"summary": "Delete a checkout key",
"description": "Deletes the checkout key via md5 or sha256 fingerprint. sha256 keys should be url-encoded.",
"tags": [
"Project"
],
"operationId": "deleteCheckoutKey",
"responses": {
"200": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "fingerprint",
"description": "An SSH key fingerprint.",
"schema": {
"type": "string"
},
"required": true,
"example": "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"summary": "Get a checkout key",
"description": "Returns an individual checkout key via md5 or sha256 fingerprint. sha256 keys should be url-encoded.",
"tags": [
"Project"
],
"operationId": "getCheckoutKey",
"responses": {
"200": {
"description": "The checkout key.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"public-key": {
"type": "string",
"description": "A public SSH key.",
"example": "ssh-rsa ..."
},
"type": {
"enum": [
"deploy-key",
"github-user-key"
],
"type": "string",
"description": "The type of checkout key. This may be either `deploy-key` or `github-user-key`.",
"title": "CheckoutKeyType",
"example": "deploy-key"
},
"fingerprint": {
"type": "string",
"description": "An SSH key fingerprint.",
"example": "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
},
"preferred": {
"type": "boolean",
"description": "A boolean value that indicates if this key is preferred.",
"example": true
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the checkout key was created.",
"example": "2015-09-21T17:29:21.042Z"
}
},
"required": [
"public-key",
"type",
"fingerprint",
"preferred",
"created-at"
],
"description": "A checkout key",
"title": "CheckoutKey"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "fingerprint",
"description": "An SSH key fingerprint.",
"schema": {
"type": "string"
},
"required": true,
"example": "c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key/c9:0b:1c:4f:d5:65:56:b9:ad:88:f9:81:2b:37:74:2f \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/envvar": {
"post": {
"summary": "Create an environment variable",
"description": "Creates a new environment variable.",
"tags": [
"Project"
],
"operationId": "createEnvVar",
"responses": {
"201": {
"description": "The environment variable.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the environment variable.",
"example": "foo"
},
"value": {
"type": "string",
"description": "The value of the environment variable.",
"example": "xxxx1234"
},
"created-at": {
"x-nullable": true,
"description": "The creation timestamp of the environment variable.",
"example": "#joda/inst 2023-04-14T21:20:14+0000"
}
},
"required": [
"name",
"value"
],
"description": "An environment variable is a map containing a value and an optional timestamp.",
"title": "EnvironmentVariable"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the environment variable.",
"example": "foo"
},
"value": {
"type": "string",
"description": "The value of the environment variable.",
"example": "xxxx1234"
}
},
"required": [
"name",
"value"
],
"description": "An environment variable request requires a name and a value",
"title": "EnvironmentVariable"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {name: 'foo', value: 'xxxx1234'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"name\\\":\\\"foo\\\",\\\"value\\\":\\\"xxxx1234\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\"\n\n\tpayload := strings.NewReader(\"{\\\"name\\\":\\\"foo\\\",\\\"value\\\":\\\"xxxx1234\\\"}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"foo\",\"value\":\"xxxx1234\"}'"
}
]
},
"get": {
"summary": "List all environment variables",
"description": "Returns four 'x' characters, in addition to the last four ASCII characters of the value, consistent with the display of environment variable values on the CircleCI website.",
"tags": [
"Project"
],
"operationId": "listEnvVars",
"responses": {
"200": {
"description": "A sequence of environment variables.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the environment variable.",
"example": "foo"
},
"value": {
"type": "string",
"description": "The value of the environment variable.",
"example": "xxxx1234"
},
"created-at": {
"x-nullable": true,
"description": "The creation timestamp of the environment variable.",
"example": "#joda/inst 2023-04-14T21:20:14+0000"
}
},
"required": [
"name",
"value"
],
"description": "An environment variable is a map containing a value and an optional timestamp.",
"title": "EnvironmentVariable"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"title": "EnvironmentVariableListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/envvar/{name}": {
"delete": {
"summary": "Delete an environment variable",
"description": "Deletes the environment variable named :name.",
"tags": [
"Project"
],
"operationId": "deleteEnvVar",
"responses": {
"200": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "name",
"description": "The name of the environment variable.",
"schema": {
"type": "string"
},
"required": true,
"example": "foo"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"summary": "Get a masked environment variable",
"description": "Returns the masked value of environment variable :name.",
"tags": [
"Project"
],
"operationId": "getEnvVar",
"responses": {
"200": {
"description": "The environment variable.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the environment variable.",
"example": "foo"
},
"value": {
"type": "string",
"description": "The value of the environment variable.",
"example": "xxxx1234"
},
"created-at": {
"x-nullable": true,
"description": "The creation timestamp of the environment variable.",
"example": "#joda/inst 2023-04-14T21:20:14+0000"
}
},
"required": [
"name",
"value"
],
"description": "An environment variable is a map containing a value and an optional timestamp.",
"title": "EnvironmentVariable"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "name",
"description": "The name of the environment variable.",
"schema": {
"type": "string"
},
"required": true,
"example": "foo"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/job/{job-number}": {
"get": {
"summary": "Get job details",
"description": "Returns job details.",
"tags": [
"Job"
],
"operationId": "getJobDetails",
"responses": {
"200": {
"description": "Job details.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"web_url": {
"type": "string",
"description": "URL of the job in CircleCI Web UI."
},
"project": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"slug": {
"type": "string",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"name": {
"type": "string",
"description": "The name of the project",
"example": "api-preview-docs"
},
"external_url": {
"type": "string",
"description": "URL to the repository hosting the project's code",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"id",
"slug",
"name",
"external_url"
],
"description": "Information about a project."
},
"parallel_runs": {
"type": "array",
"items": {
"type": "object",
"properties": {
"index": {
"type": "integer",
"format": "int64",
"description": "Index of the parallel run."
},
"status": {
"type": "string",
"description": "Status of the parallel run."
}
},
"required": [
"index",
"status"
],
"description": "Info about a status of the parallel run."
},
"description": "Info about parallels runs and their status."
},
"started_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the job started."
},
"latest_workflow": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the workflow."
},
"name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
}
},
"required": [
"id",
"name"
],
"description": "Info about the latest workflow the job was a part of."
},
"name": {
"type": "string",
"description": "The name of the job."
},
"executor": {
"type": "object",
"properties": {
"resource_class": {
"type": "string",
"description": "Resource class name."
},
"type": {
"type": "string",
"description": "Executor type."
}
},
"required": [
"resource_class"
],
"description": "Information about executor used for a job."
},
"parallelism": {
"type": "integer",
"format": "int64",
"description": "A number of parallel runs the job has."
},
"status": {
"enum": [
"success",
"running",
"not_run",
"failed",
"retried",
"queued",
"not_running",
"infrastructure_fail",
"timedout",
"on_hold",
"terminated-unknown",
"blocked",
"canceled",
"unauthorized"
],
"type": "string",
"description": "The current status of the job."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the job."
},
"pipeline": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
},
"required": [
"id"
],
"description": "Info about a pipeline the job is a part of."
},
"duration": {
"type": "integer",
"format": "int64",
"x-nullable": true,
"description": "Duration of a job in milliseconds."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The time when the job was created."
},
"messages": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"type": "string",
"description": "Message type."
},
"message": {
"type": "string",
"description": "Information describing message."
},
"reason": {
"type": "string",
"description": "Value describing the reason for message to be added to the job."
}
},
"required": [
"type",
"message"
],
"description": "Message from CircleCI execution platform."
},
"description": "Messages from CircleCI execution platform."
},
"contexts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the context."
}
},
"required": [
"name"
],
"description": "Information about the context."
},
"description": "List of contexts used by the job."
},
"organization": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "The name of the organization."
}
},
"required": [
"name"
],
"description": "Information about an organization."
},
"queued_at": {
"type": "string",
"format": "date-time",
"description": "The time when the job was placed in a queue."
},
"stopped_at": {
"type": "string",
"format": "date-time",
"x-nullable": true,
"description": "The time when the job stopped."
}
},
"required": [
"number",
"name",
"status",
"started_at",
"created_at",
"queued_at",
"duration",
"executor",
"project",
"organization",
"contexts",
"web_url",
"parallel_runs",
"latest_workflow",
"pipeline",
"parallelism",
"messages"
],
"description": "Job Details",
"title": "Job Details"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "job-number",
"description": "The number of the job.",
"schema": {},
"required": true,
"example": "123"
},
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123 \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/job/{job-number}/cancel": {
"post": {
"summary": "Cancel job",
"description": "Cancel job with a given job number.",
"tags": [
"Job"
],
"operationId": "cancelJob",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
},
"description": ""
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "job-number",
"description": "The number of the job.",
"schema": {},
"required": true,
"example": "123"
},
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel\"\n\n\treq, _ := http.NewRequest(\"POST\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/pipeline": {
"get": {
"summary": "Get all pipelines",
"description": "Returns all pipelines for this project.",
"tags": [
"Pipeline"
],
"operationId": "listPipelinesForProject",
"responses": {
"200": {
"description": "A sequence of pipelines.",
"links": {
"NextPipelinePage": {
"operationId": "listPipelinesForProject",
"parameters": {
"project-slug": "$request.path.project-slug",
"page-token": "$response.body#/next_page_token"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"config",
"config-fetch",
"timeout",
"permission",
"other",
"trigger-rule",
"plan"
],
"type": "string",
"description": "The type of error."
},
"message": {
"type": "string",
"description": "A human-readable error message."
}
},
"required": [
"type",
"message"
],
"description": "An error with a type and message."
},
"description": "A sequence of errors that have occurred within the pipeline."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"trigger_parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "boolean"
},
{
"type": "object"
}
]
}
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"trigger": {
"type": "object",
"properties": {
"type": {
"enum": [
"scheduled_pipeline",
"explicit",
"api",
"webhook"
],
"type": "string",
"description": "The type of trigger."
},
"received_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the trigger was received."
},
"actor": {
"type": "object",
"properties": {
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"avatar_url": {
"type": "string",
"x-nullable": true,
"description": "URL to the user's avatar on the VCS"
}
},
"required": [
"login",
"avatar_url"
],
"description": "The user who triggered the Pipeline."
}
},
"required": [
"type",
"received_at",
"actor"
],
"description": "A summary of the trigger."
},
"vcs": {
"type": "object",
"properties": {
"provider_name": {
"type": "string",
"description": "Name of the VCS provider (e.g. GitHub, Bitbucket).",
"example": "GitHub"
},
"target_repository_url": {
"type": "string",
"description": "URL for the repository the trigger targets (i.e. the repository where the PR will be merged). For fork-PR pipelines, this is the URL to the parent repo. For other pipelines, the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"review_id": {
"type": "string",
"description": "The code review id.",
"example": "123"
},
"review_url": {
"type": "string",
"description": "The code review URL.",
"example": "https://github.com/CircleCI-Public/api-preview-docs/pull/123"
},
"revision": {
"type": "string",
"description": "The code revision the pipeline ran.",
"example": "f454a02b5d10fcccfd7d9dd7608a76d6493a98b4"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"commit": {
"type": "object",
"properties": {
"subject": {
"type": "string",
"x-nullable": true,
"description": "The subject of the commit message."
},
"body": {
"type": "string",
"x-nullable": true,
"description": "The body of the commit message."
}
},
"required": [
"subject",
"body"
],
"description": "The latest commit in the pipeline."
},
"origin_repository_url": {
"type": "string",
"description": "URL for the repository where the trigger originated. For fork-PR pipelines, this is the URL to the fork. For other pipelines the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"provider_name",
"origin_repository_url",
"target_repository_url",
"revision"
],
"description": "VCS information for the pipeline."
}
},
"required": [
"id",
"number",
"project_slug",
"created_at",
"errors",
"state",
"trigger"
],
"description": "A pipeline response.",
"title": "Pipeline"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "List of pipelines",
"title": "PipelineListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "branch",
"description": "The name of a vcs branch.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline',\n qs: {branch: 'SOME_STRING_VALUE', 'page-token': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline?branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline?branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline?branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"post": {
"summary": "Trigger a new pipeline",
"description": "Not yet available to projects that use GitLab or GitHub App. Triggers a new pipeline on the project.",
"tags": [
"Pipeline"
],
"operationId": "triggerPipeline",
"responses": {
"201": {
"description": "The created pipeline.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
}
},
"required": [
"id",
"state",
"number",
"created_at"
],
"description": "A pipeline creation response.",
"title": "PipelineCreation"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "An object containing pipeline parameters and their values. Pipeline parameters have the following size limits: 100 max entries, 128 maximum key length, 512 maximum value length.",
"example": {
"deploy_prod": true
}
}
},
"x-nullable": true,
"description": "The information you can supply when triggering a pipeline.",
"title": "TriggerPipelineParameters"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n branch: 'feature/design-new-api',\n tag: 'v3.1.4159',\n parameters: {deploy_prod: true}\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"branch\\\":\\\"feature/design-new-api\\\",\\\"tag\\\":\\\"v3.1.4159\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline\"\n\n\tpayload := strings.NewReader(\"{\\\"branch\\\":\\\"feature/design-new-api\\\",\\\"tag\\\":\\\"v3.1.4159\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"branch\":\"feature/design-new-api\",\"tag\":\"v3.1.4159\",\"parameters\":{\"deploy_prod\":true}}'"
}
]
}
},
"/project/{project-slug}/pipeline/mine": {
"get": {
"summary": "Get your pipelines",
"description": "Returns a sequence of all pipelines for this project triggered by the user.",
"tags": [
"Pipeline"
],
"operationId": "listMyPipelines",
"responses": {
"200": {
"description": "A sequence of pipelines.",
"links": {
"NextPipelinePage": {
"operationId": "listMyPipelines",
"parameters": {
"project-slug": "$request.path.project-slug",
"page-token": "$response.body#/next_page_token"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"config",
"config-fetch",
"timeout",
"permission",
"other",
"trigger-rule",
"plan"
],
"type": "string",
"description": "The type of error."
},
"message": {
"type": "string",
"description": "A human-readable error message."
}
},
"required": [
"type",
"message"
],
"description": "An error with a type and message."
},
"description": "A sequence of errors that have occurred within the pipeline."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"trigger_parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "boolean"
},
{
"type": "object"
}
]
}
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"trigger": {
"type": "object",
"properties": {
"type": {
"enum": [
"scheduled_pipeline",
"explicit",
"api",
"webhook"
],
"type": "string",
"description": "The type of trigger."
},
"received_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the trigger was received."
},
"actor": {
"type": "object",
"properties": {
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"avatar_url": {
"type": "string",
"x-nullable": true,
"description": "URL to the user's avatar on the VCS"
}
},
"required": [
"login",
"avatar_url"
],
"description": "The user who triggered the Pipeline."
}
},
"required": [
"type",
"received_at",
"actor"
],
"description": "A summary of the trigger."
},
"vcs": {
"type": "object",
"properties": {
"provider_name": {
"type": "string",
"description": "Name of the VCS provider (e.g. GitHub, Bitbucket).",
"example": "GitHub"
},
"target_repository_url": {
"type": "string",
"description": "URL for the repository the trigger targets (i.e. the repository where the PR will be merged). For fork-PR pipelines, this is the URL to the parent repo. For other pipelines, the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"review_id": {
"type": "string",
"description": "The code review id.",
"example": "123"
},
"review_url": {
"type": "string",
"description": "The code review URL.",
"example": "https://github.com/CircleCI-Public/api-preview-docs/pull/123"
},
"revision": {
"type": "string",
"description": "The code revision the pipeline ran.",
"example": "f454a02b5d10fcccfd7d9dd7608a76d6493a98b4"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"commit": {
"type": "object",
"properties": {
"subject": {
"type": "string",
"x-nullable": true,
"description": "The subject of the commit message."
},
"body": {
"type": "string",
"x-nullable": true,
"description": "The body of the commit message."
}
},
"required": [
"subject",
"body"
],
"description": "The latest commit in the pipeline."
},
"origin_repository_url": {
"type": "string",
"description": "URL for the repository where the trigger originated. For fork-PR pipelines, this is the URL to the fork. For other pipelines the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"provider_name",
"origin_repository_url",
"target_repository_url",
"revision"
],
"description": "VCS information for the pipeline."
}
},
"required": [
"id",
"number",
"project_slug",
"created_at",
"errors",
"state",
"trigger"
],
"description": "A pipeline response.",
"title": "Pipeline"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "List of pipelines",
"title": "PipelineListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/mine',\n qs: {'page-token': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/mine?page-token=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/mine?page-token=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/mine?page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/pipeline/{pipeline-number}": {
"get": {
"summary": "Get a pipeline by pipeline number",
"description": "Returns a pipeline by the pipeline number.",
"tags": [
"Pipeline"
],
"operationId": "getPipelineByNumber",
"responses": {
"200": {
"description": "A pipeline object.",
"links": {
"ProjectFromPipeline": {
"operationId": "getProjectBySlug",
"parameters": {
"project_slug": "$response.body#/project_slug"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the pipeline.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"errors": {
"type": "array",
"items": {
"type": "object",
"properties": {
"type": {
"enum": [
"config",
"config-fetch",
"timeout",
"permission",
"other",
"trigger-rule",
"plan"
],
"type": "string",
"description": "The type of error."
},
"message": {
"type": "string",
"description": "A human-readable error message."
}
},
"required": [
"type",
"message"
],
"description": "An error with a type and message."
},
"description": "A sequence of errors that have occurred within the pipeline."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"updated_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline.",
"example": "25"
},
"trigger_parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "string"
},
{
"type": "integer",
"format": "int64"
},
{
"type": "boolean"
},
{
"type": "object"
}
]
}
},
"state": {
"enum": [
"created",
"errored",
"setup-pending",
"setup",
"pending"
],
"type": "string",
"description": "The current state of the pipeline."
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"trigger": {
"type": "object",
"properties": {
"type": {
"enum": [
"scheduled_pipeline",
"explicit",
"api",
"webhook"
],
"type": "string",
"description": "The type of trigger."
},
"received_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the trigger was received."
},
"actor": {
"type": "object",
"properties": {
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"avatar_url": {
"type": "string",
"x-nullable": true,
"description": "URL to the user's avatar on the VCS"
}
},
"required": [
"login",
"avatar_url"
],
"description": "The user who triggered the Pipeline."
}
},
"required": [
"type",
"received_at",
"actor"
],
"description": "A summary of the trigger."
},
"vcs": {
"type": "object",
"properties": {
"provider_name": {
"type": "string",
"description": "Name of the VCS provider (e.g. GitHub, Bitbucket).",
"example": "GitHub"
},
"target_repository_url": {
"type": "string",
"description": "URL for the repository the trigger targets (i.e. the repository where the PR will be merged). For fork-PR pipelines, this is the URL to the parent repo. For other pipelines, the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
},
"branch": {
"type": "string",
"description": "The branch where the pipeline ran. The HEAD commit on this branch was used for the pipeline. Note that `branch` and `tag` are mutually exclusive. To trigger a pipeline for a PR by number use `pull/<number>/head` for the PR ref or `pull/<number>/merge` for the merge ref (GitHub only).",
"example": "feature/design-new-api"
},
"review_id": {
"type": "string",
"description": "The code review id.",
"example": "123"
},
"review_url": {
"type": "string",
"description": "The code review URL.",
"example": "https://github.com/CircleCI-Public/api-preview-docs/pull/123"
},
"revision": {
"type": "string",
"description": "The code revision the pipeline ran.",
"example": "f454a02b5d10fcccfd7d9dd7608a76d6493a98b4"
},
"tag": {
"type": "string",
"description": "The tag used by the pipeline. The commit that this tag points to was used for the pipeline. Note that `branch` and `tag` are mutually exclusive.",
"example": "v3.1.4159"
},
"commit": {
"type": "object",
"properties": {
"subject": {
"type": "string",
"x-nullable": true,
"description": "The subject of the commit message."
},
"body": {
"type": "string",
"x-nullable": true,
"description": "The body of the commit message."
}
},
"required": [
"subject",
"body"
],
"description": "The latest commit in the pipeline."
},
"origin_repository_url": {
"type": "string",
"description": "URL for the repository where the trigger originated. For fork-PR pipelines, this is the URL to the fork. For other pipelines the `origin_` and `target_repository_url`s will be the same.",
"example": "https://github.com/CircleCI-Public/api-preview-docs"
}
},
"required": [
"provider_name",
"origin_repository_url",
"target_repository_url",
"revision"
],
"description": "VCS information for the pipeline."
}
},
"required": [
"id",
"number",
"project_slug",
"created_at",
"errors",
"state",
"trigger"
],
"description": "A pipeline response.",
"title": "Pipeline"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "path",
"name": "pipeline-number",
"description": "The number of the pipeline.",
"schema": {},
"required": true,
"example": "123"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/123',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/123\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/123\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/123 \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/schedule": {
"get": {
"summary": "Get all schedules",
"description": "Returns all schedules for this project.",
"tags": [
"Schedule"
],
"operationId": "listSchedulesForProject",
"responses": {
"200": {
"description": "A sequence of schedules.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the schedule."
},
"timetable": {
"anyOf": [
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-week"
]
},
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-month"
]
}
],
"description": "Timetable that specifies when a schedule triggers."
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"name": {
"type": "string",
"description": "Name of the schedule."
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"project-slug": {
"type": "string",
"description": "The project-slug for the schedule",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
},
"actor": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User",
"description": "The attribution actor who will run the scheduled pipeline."
},
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
}
},
"required": [
"id",
"name",
"timetable",
"description",
"project-slug",
"actor",
"created-at",
"updated-at",
"parameters"
],
"description": "A schedule response",
"title": "Schedule"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "A sequence of schedules"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
},
{
"in": "query",
"name": "page-token",
"description": "A token to retrieve the next page of results.",
"schema": {
"type": "string"
},
"required": false,
"allowEmptyValue": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule',\n qs: {'page-token': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule?page-token=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule?page-token=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule?page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"post": {
"summary": "Create a schedule",
"description": "Not yet available to projects that use GitLab or GitHub App. Creates a schedule and returns the created schedule.",
"tags": [
"Schedule"
],
"operationId": "createSchedule",
"responses": {
"201": {
"description": "A schedule object.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the schedule."
},
"timetable": {
"anyOf": [
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-week"
]
},
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-month"
]
}
],
"description": "Timetable that specifies when a schedule triggers."
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"name": {
"type": "string",
"description": "Name of the schedule."
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"project-slug": {
"type": "string",
"description": "The project-slug for the schedule",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
},
"actor": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User",
"description": "The attribution actor who will run the scheduled pipeline."
},
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
}
},
"required": [
"id",
"name",
"timetable",
"description",
"project-slug",
"actor",
"created-at",
"updated-at",
"parameters"
],
"description": "A schedule response",
"title": "Schedule"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the schedule."
},
"timetable": {
"anyOf": [
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-week"
]
},
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-month"
]
}
],
"description": "Timetable that specifies when a schedule triggers."
},
"attribution-actor": {
"enum": [
"current",
"system"
],
"type": "string",
"description": "The attribution-actor of the scheduled pipeline.",
"example": "current"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
},
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
}
},
"required": [
"name",
"timetable",
"attribution-actor",
"parameters"
],
"description": "The parameters for a create schedule request",
"title": "CreateScheduleParameters"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n name: 'string',\n timetable: {\n 'per-hour': 0,\n 'hours-of-day': [0],\n 'days-of-week': ['TUE'],\n 'days-of-month': [0],\n months: ['MAR']\n },\n 'attribution-actor': 'current',\n parameters: {deploy_prod: true, branch: 'feature/design-new-api'},\n description: 'string'\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"],\\\"days-of-month\\\":[0],\\\"months\\\":[\\\"MAR\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"},\\\"description\\\":\\\"string\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule\"\n\n\tpayload := strings.NewReader(\"{\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"],\\\"days-of-month\\\":[0],\\\"months\\\":[\\\"MAR\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"},\\\"description\\\":\\\"string\\\"}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"string\",\"timetable\":{\"per-hour\":0,\"hours-of-day\":[0],\"days-of-week\":[\"TUE\"],\"days-of-month\":[0],\"months\":[\"MAR\"]},\"attribution-actor\":\"current\",\"parameters\":{\"deploy_prod\":true,\"branch\":\"feature/design-new-api\"},\"description\":\"string\"}'"
}
]
}
},
"/project/{project-slug}/{job-number}/artifacts": {
"get": {
"summary": "Get a job's artifacts",
"description": "Returns a job's artifacts.",
"tags": [
"Job"
],
"operationId": "getJobArtifacts",
"responses": {
"200": {
"description": "A paginated list of the job's artifacts.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"path": {
"type": "string",
"description": "The artifact path."
},
"node_index": {
"type": "integer",
"format": "int64",
"minimum": 0,
"description": "The index of the node that stored the artifact."
},
"url": {
"type": "string",
"description": "The URL to download the artifact contents."
}
},
"required": [
"path",
"node_index",
"url"
],
"description": "An artifact",
"title": "Artifact"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"title": "ArtifactListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "job-number",
"description": "The number of the job.",
"schema": {},
"required": true,
"example": "123"
},
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/artifacts',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/artifacts\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/artifacts\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/artifacts \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{project-slug}/{job-number}/tests": {
"get": {
"summary": "Get test metadata",
"description": "Get test metadata for a build. In the rare case where there is more than 250MB of test data on the job, no results will be returned.",
"tags": [
"Job"
],
"operationId": "getTests",
"responses": {
"200": {
"description": "A paginated list of test results.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"message": {
"type": "string",
"x-nullable": true,
"description": "The failure message associated with the test.",
"example": ""
},
"source": {
"type": "string",
"description": "The program that generated the test results",
"example": ""
},
"run_time": {
"type": "number",
"format": "double",
"description": "The time it took to run the test in seconds",
"example": ""
},
"file": {
"type": "string",
"description": "The file in which the test is defined.",
"example": ""
},
"result": {
"type": "string",
"description": "Indication of whether the test succeeded.",
"example": ""
},
"name": {
"type": "string",
"description": "The name of the test.",
"example": ""
},
"classname": {
"type": "string",
"description": "The programmatic location of the test.",
"example": ""
}
},
"required": [
"message",
"source",
"run_time",
"file",
"result",
"name",
"classname"
]
},
"title": "TestsResponse"
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"title": "TestsResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "job-number",
"description": "The number of the job.",
"schema": {},
"required": true,
"example": "123"
},
{
"in": "path",
"name": "project-slug",
"description": "Project slug in the form `vcs-slug/org-name/repo-name`. The `/` characters may be URL-escaped. For projects that use GitLab or GitHub App, use `circleci` as the `vcs-slug`, replace `org-name` with the organization ID (found in Organization Settings), and replace `repo-name` with the project ID (found in Project Settings).",
"schema": {
"type": "string"
},
"required": true,
"example": "gh/CircleCI-Public/api-preview-docs",
"allowReserved": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/tests',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/tests\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/tests\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/tests \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/schedule/{schedule-id}": {
"patch": {
"summary": "Update a schedule",
"description": "Not yet available to projects that use GitLab or GitHub App. Updates a schedule and returns the updated schedule.",
"tags": [
"Schedule"
],
"operationId": "updateSchedule",
"responses": {
"200": {
"description": "A schedule object.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the schedule."
},
"timetable": {
"anyOf": [
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-week"
]
},
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-month"
]
}
],
"description": "Timetable that specifies when a schedule triggers."
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"name": {
"type": "string",
"description": "Name of the schedule."
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"project-slug": {
"type": "string",
"description": "The project-slug for the schedule",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
},
"actor": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User",
"description": "The attribution actor who will run the scheduled pipeline."
},
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
}
},
"required": [
"id",
"name",
"timetable",
"description",
"project-slug",
"actor",
"created-at",
"updated-at",
"parameters"
],
"description": "A schedule response",
"title": "Schedule"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "schedule-id",
"description": "The unique ID of the schedule.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
},
"name": {
"type": "string",
"description": "Name of the schedule."
},
"timetable": {
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"description": "Timetable that specifies when a schedule triggers."
},
"attribution-actor": {
"enum": [
"current",
"system"
],
"type": "string",
"description": "The attribution-actor of the scheduled pipeline.",
"example": "current"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
}
},
"description": "The parameters for an update schedule request",
"title": "UpdateScheduleParameters"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PATCH',\n url: 'https://circleci.com/api/v2/schedule/%7Bschedule-id%7D',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n description: 'string',\n name: 'string',\n timetable: {\n 'per-hour': 0,\n 'hours-of-day': [0],\n 'days-of-week': ['TUE'],\n 'days-of-month': [0],\n months: ['MAR']\n },\n 'attribution-actor': 'current',\n parameters: {deploy_prod: true, branch: 'feature/design-new-api'}\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"description\\\":\\\"string\\\",\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"],\\\"days-of-month\\\":[0],\\\"months\\\":[\\\"MAR\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PATCH\", \"/api/v2/schedule/%7Bschedule-id%7D\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\"\n\n\tpayload := strings.NewReader(\"{\\\"description\\\":\\\"string\\\",\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"],\\\"days-of-month\\\":[0],\\\"months\\\":[\\\"MAR\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"}}\")\n\n\treq, _ := http.NewRequest(\"PATCH\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PATCH \\\n --url https://circleci.com/api/v2/schedule/%7Bschedule-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"description\":\"string\",\"name\":\"string\",\"timetable\":{\"per-hour\":0,\"hours-of-day\":[0],\"days-of-week\":[\"TUE\"],\"days-of-month\":[0],\"months\":[\"MAR\"]},\"attribution-actor\":\"current\",\"parameters\":{\"deploy_prod\":true,\"branch\":\"feature/design-new-api\"}}'"
}
]
},
"delete": {
"summary": "Delete a schedule",
"description": "Not yet available to projects that use GitLab or GitHub App. Deletes the schedule by id.",
"tags": [
"Schedule"
],
"operationId": "deleteScheduleById",
"responses": {
"200": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "schedule-id",
"description": "The unique ID of the schedule.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/schedule/%7Bschedule-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/schedule/%7Bschedule-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/schedule/%7Bschedule-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"summary": "Get a schedule",
"description": "Get a schedule by id.",
"tags": [
"Schedule"
],
"operationId": "getScheduleById",
"responses": {
"200": {
"description": "A schedule object.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the schedule."
},
"timetable": {
"anyOf": [
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-week"
]
},
{
"type": "object",
"properties": {
"per-hour": {
"type": "integer",
"format": "integer",
"description": "Number of times a schedule triggers per hour, value must be between 1 and 60"
},
"hours-of-day": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Hour in a day in UTC, value must be between 0 and 24"
},
"description": "Hours in a day in which the schedule triggers."
},
"days-of-month": {
"type": "array",
"items": {
"type": "integer",
"format": "integer",
"description": "Day in a month, between 1 and 31."
},
"description": "Days in a month in which the schedule triggers. This is mutually exclusive with days in a week."
},
"days-of-week": {
"type": "array",
"items": {
"enum": [
"TUE",
"SAT",
"SUN",
"MON",
"THU",
"WED",
"FRI"
],
"type": "string",
"description": "Day in a week, in three letters format"
},
"description": "Days in a week in which the schedule triggers."
},
"months": {
"type": "array",
"items": {
"enum": [
"MAR",
"NOV",
"DEC",
"JUN",
"MAY",
"OCT",
"FEB",
"APR",
"SEP",
"AUG",
"JAN",
"JUL"
],
"type": "string",
"description": "Month, in three letters format."
},
"description": "Months in which the schedule triggers."
}
},
"required": [
"per-hour",
"hours-of-day",
"days-of-month"
]
}
],
"description": "Timetable that specifies when a schedule triggers."
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was last updated."
},
"name": {
"type": "string",
"description": "Name of the schedule."
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the pipeline was created."
},
"project-slug": {
"type": "string",
"description": "The project-slug for the schedule",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"parameters": {
"type": "object",
"additionalProperties": {
"anyOf": [
{
"type": "integer"
},
{
"type": "string"
},
{
"type": "boolean"
}
]
},
"description": "Pipeline parameters represented as key-value pairs. Must contain branch or tag.",
"example": {
"deploy_prod": true,
"branch": "feature/design-new-api"
}
},
"actor": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User",
"description": "The attribution actor who will run the scheduled pipeline."
},
"description": {
"type": "string",
"x-nullable": true,
"description": "Description of the schedule."
}
},
"required": [
"id",
"name",
"timetable",
"description",
"project-slug",
"actor",
"created-at",
"updated-at",
"parameters"
],
"description": "A schedule response",
"title": "Schedule"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "schedule-id",
"description": "The unique ID of the schedule.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/schedule/%7Bschedule-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/schedule/%7Bschedule-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/schedule/%7Bschedule-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/user/{id}": {
"get": {
"summary": "User Information",
"description": "Provides information about the user with the given ID.",
"tags": [
"User"
],
"operationId": "getUser",
"responses": {
"200": {
"description": "User login information.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"login": {
"type": "string",
"description": "The login information for the user on the VCS.",
"title": "Login"
},
"name": {
"type": "string",
"description": "The name of the user."
}
},
"required": [
"id",
"login",
"name"
],
"title": "User"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The unique ID of the user.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/user/%7Bid%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/user/%7Bid%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/user/%7Bid%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/user/%7Bid%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/webhook": {
"post": {
"summary": "Create an outbound webhook",
"description": "Creates an outbound webhook.",
"tags": [
"Webhook"
],
"operationId": "createWebhook",
"responses": {
"201": {
"description": "A webhook",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the webhook"
},
"signing-secret": {
"type": "string",
"description": "Masked value of the secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was last updated.",
"example": "2015-09-21T17:29:21.042Z"
},
"name": {
"type": "string",
"description": "Name of the webhook"
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "ID of the scope being used (at the moment, only project ID is supported)"
},
"type": {
"type": "string",
"description": "Type of the scope being used"
}
},
"required": [
"id",
"type"
],
"description": "The scope in which the relevant events that will trigger webhooks"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
}
},
"required": [
"id",
"scope",
"name",
"events",
"url",
"verify-tls",
"signing-secret",
"created-at",
"updated-at"
],
"title": "Webhook"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the webhook"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
},
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
},
"signing-secret": {
"type": "string",
"description": "Secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "ID of the scope being used (at the moment, only project ID is supported)"
},
"type": {
"enum": [
"project"
],
"type": "string",
"description": "Type of the scope being used"
}
},
"required": [
"id",
"type"
],
"description": "The scope in which the relevant events that will trigger webhooks"
}
},
"required": [
"name",
"events",
"url",
"verify-tls",
"signing-secret",
"scope"
],
"description": "The parameters for a create webhook request"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/webhook',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n name: 'string',\n events: ['workflow-completed'],\n url: 'string',\n 'verify-tls': true,\n 'signing-secret': 'string',\n scope: {id: 'string', type: 'project'}\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"name\\\":\\\"string\\\",\\\"events\\\":[\\\"workflow-completed\\\"],\\\"url\\\":\\\"string\\\",\\\"verify-tls\\\":true,\\\"signing-secret\\\":\\\"string\\\",\\\"scope\\\":{\\\"id\\\":\\\"string\\\",\\\"type\\\":\\\"project\\\"}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/webhook\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/webhook\"\n\n\tpayload := strings.NewReader(\"{\\\"name\\\":\\\"string\\\",\\\"events\\\":[\\\"workflow-completed\\\"],\\\"url\\\":\\\"string\\\",\\\"verify-tls\\\":true,\\\"signing-secret\\\":\\\"string\\\",\\\"scope\\\":{\\\"id\\\":\\\"string\\\",\\\"type\\\":\\\"project\\\"}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/webhook \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"string\",\"events\":[\"workflow-completed\"],\"url\":\"string\",\"verify-tls\":true,\"signing-secret\":\"string\",\"scope\":{\"id\":\"string\",\"type\":\"project\"}}'"
}
]
},
"get": {
"summary": "List webhooks",
"description": "Get a list of outbound webhooks that match the given scope-type and scope-id",
"tags": [
"Webhook"
],
"operationId": "getWebhooks",
"responses": {
"200": {
"description": "A list of webhooks",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the webhook"
},
"signing-secret": {
"type": "string",
"description": "Masked value of the secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was last updated.",
"example": "2015-09-21T17:29:21.042Z"
},
"name": {
"type": "string",
"description": "Name of the webhook"
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "ID of the scope being used (at the moment, only project ID is supported)"
},
"type": {
"type": "string",
"description": "Type of the scope being used"
}
},
"required": [
"id",
"type"
],
"description": "The scope in which the relevant events that will trigger webhooks"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
}
},
"required": [
"id",
"scope",
"name",
"events",
"url",
"verify-tls",
"signing-secret",
"created-at",
"updated-at"
],
"title": "Webhook"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"description": "A list of webhooks"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "query",
"name": "scope-id",
"description": "ID of the scope being used (at the moment, only project ID is supported)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
},
{
"in": "query",
"name": "scope-type",
"description": "Type of the scope being used",
"schema": {
"type": "string",
"enum": [
"project"
]
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/webhook',\n qs: {'scope-id': 'SOME_STRING_VALUE', 'scope-type': 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/webhook?scope-id=SOME_STRING_VALUE&scope-type=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/webhook?scope-id=SOME_STRING_VALUE&scope-type=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/webhook?scope-id=SOME_STRING_VALUE&scope-type=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/webhook/{webhook-id}": {
"get": {
"summary": "Get a webhook",
"description": "Get an outbound webhook by id.",
"tags": [
"Webhook"
],
"operationId": "getWebhookById",
"responses": {
"200": {
"description": "A webhook",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the webhook"
},
"signing-secret": {
"type": "string",
"description": "Masked value of the secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was last updated.",
"example": "2015-09-21T17:29:21.042Z"
},
"name": {
"type": "string",
"description": "Name of the webhook"
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "ID of the scope being used (at the moment, only project ID is supported)"
},
"type": {
"type": "string",
"description": "Type of the scope being used"
}
},
"required": [
"id",
"type"
],
"description": "The scope in which the relevant events that will trigger webhooks"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
}
},
"required": [
"id",
"scope",
"name",
"events",
"url",
"verify-tls",
"signing-secret",
"created-at",
"updated-at"
],
"title": "Webhook"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "webhook-id",
"description": "ID of the webhook (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/webhook/%7Bwebhook-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"put": {
"summary": "Update an outbound webhook",
"description": "Updates an outbound webhook.",
"tags": [
"Webhook"
],
"operationId": "updateWebhook",
"responses": {
"200": {
"description": "A webhook",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the webhook"
},
"signing-secret": {
"type": "string",
"description": "Masked value of the secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"updated-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was last updated.",
"example": "2015-09-21T17:29:21.042Z"
},
"name": {
"type": "string",
"description": "Name of the webhook"
},
"created-at": {
"type": "string",
"format": "date-time",
"description": "The date and time the webhook was created.",
"example": "2015-09-21T17:29:21.042Z"
},
"scope": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "ID of the scope being used (at the moment, only project ID is supported)"
},
"type": {
"type": "string",
"description": "Type of the scope being used"
}
},
"required": [
"id",
"type"
],
"description": "The scope in which the relevant events that will trigger webhooks"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
}
},
"required": [
"id",
"scope",
"name",
"events",
"url",
"verify-tls",
"signing-secret",
"created-at",
"updated-at"
],
"title": "Webhook"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "webhook-id",
"description": "ID of the webhook (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of the webhook"
},
"events": {
"type": "array",
"items": {
"enum": [
"workflow-completed",
"job-completed"
],
"type": "string"
},
"description": "Events that will trigger the webhook"
},
"url": {
"type": "string",
"description": "URL to deliver the webhook to. Note: protocol must be included as well (only https is supported)"
},
"signing-secret": {
"type": "string",
"description": "Secret used to build an HMAC hash of the payload and passed as a header in the webhook request"
},
"verify-tls": {
"type": "boolean",
"description": "Whether to enforce TLS certificate verification when delivering the webhook"
}
},
"description": "The parameters for an update webhook request"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PUT',\n url: 'https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n name: 'string',\n events: ['workflow-completed'],\n url: 'string',\n 'signing-secret': 'string',\n 'verify-tls': true\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"name\\\":\\\"string\\\",\\\"events\\\":[\\\"workflow-completed\\\"],\\\"url\\\":\\\"string\\\",\\\"signing-secret\\\":\\\"string\\\",\\\"verify-tls\\\":true}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PUT\", \"/api/v2/webhook/%7Bwebhook-id%7D\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D\"\n\n\tpayload := strings.NewReader(\"{\\\"name\\\":\\\"string\\\",\\\"events\\\":[\\\"workflow-completed\\\"],\\\"url\\\":\\\"string\\\",\\\"signing-secret\\\":\\\"string\\\",\\\"verify-tls\\\":true}\")\n\n\treq, _ := http.NewRequest(\"PUT\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PUT \\\n --url https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"name\":\"string\",\"events\":[\"workflow-completed\"],\"url\":\"string\",\"signing-secret\":\"string\",\"verify-tls\":true}'"
}
]
},
"delete": {
"summary": "Delete an outbound webhook",
"description": "Deletes an outbound webhook",
"tags": [
"Webhook"
],
"operationId": "deleteWebhook",
"responses": {
"200": {
"description": "A confirmation message",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "webhook-id",
"description": "ID of the webhook (UUID)",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/webhook/%7Bwebhook-id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/webhook/%7Bwebhook-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/workflow/{id}": {
"get": {
"summary": "Get a workflow",
"description": "Returns summary fields of a workflow by ID.",
"tags": [
"Workflow"
],
"operationId": "getWorkflowById",
"responses": {
"200": {
"description": "A workflow object.",
"links": {
"ProjectFromGetWorkflow": {
"operationId": "getProjectBySlug",
"parameters": {
"project_slug": "$response.body#/project_slug"
}
},
"WorkflowJobs": {
"operationId": "listWorkflowJobs",
"parameters": {
"id": "$response.body#/id"
}
},
"CancelWorkflow": {
"operationId": "cancelWorkflow",
"parameters": {
"id": "$response.body#/id"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"pipeline_id": {
"type": "string",
"format": "uuid",
"description": "The ID of the pipeline this workflow belongs to.",
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
},
"canceled_by": {
"type": "string",
"format": "uuid"
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the workflow."
},
"name": {
"type": "string",
"description": "The name of the workflow.",
"example": "build-and-test"
},
"project_slug": {
"type": "string",
"description": "The project-slug for the pipeline this workflow belongs to.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"errored_by": {
"type": "string",
"format": "uuid"
},
"tag": {
"enum": [
"setup"
],
"type": "string",
"x-nullable": true,
"description": "Tag used for the workflow",
"example": "setup"
},
"status": {
"enum": [
"success",
"running",
"not_run",
"failed",
"error",
"failing",
"on_hold",
"canceled",
"unauthorized"
],
"type": "string",
"description": "The current status of the workflow."
},
"started_by": {
"type": "string",
"format": "uuid"
},
"pipeline_number": {
"type": "integer",
"format": "int64",
"description": "The number of the pipeline this workflow belongs to.",
"example": "25"
},
"created_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the workflow was created."
},
"stopped_at": {
"type": "string",
"format": "date-time",
"x-nullable": true,
"description": "The date and time the workflow stopped."
}
},
"required": [
"id",
"name",
"status",
"created_at",
"stopped_at",
"pipeline_id",
"pipeline_number",
"project_slug",
"started_by"
],
"description": "A workflow",
"title": "Workflow"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The unique ID of the workflow.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/workflow/{id}/approve/{approval_request_id}": {
"post": {
"summary": "Approve a job",
"description": "Approves a pending approval job in a workflow.",
"tags": [
"Workflow"
],
"operationId": "approvePendingApprovalJobById",
"responses": {
"202": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "approval_request_id",
"description": "The ID of the job being approved.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true
},
{
"in": "path",
"name": "id",
"description": "The unique ID of the workflow.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/approve/%7Bapproval_request_id%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"POST\", \"/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/approve/%7Bapproval_request_id%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/approve/%7Bapproval_request_id%7D\"\n\n\treq, _ := http.NewRequest(\"POST\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/approve/%7Bapproval_request_id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/workflow/{id}/cancel": {
"post": {
"summary": "Cancel a workflow",
"description": "Cancels a running workflow.",
"tags": [
"Workflow"
],
"operationId": "cancelWorkflow",
"responses": {
"202": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string",
"description": "A human-readable message"
}
},
"required": [
"message"
],
"description": "message response",
"title": "MessageResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The unique ID of the workflow.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/cancel',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"POST\", \"/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/cancel\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/cancel\"\n\n\treq, _ := http.NewRequest(\"POST\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/cancel \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/workflow/{id}/job": {
"get": {
"summary": "Get a workflow's jobs",
"description": "Returns a sequence of jobs for a workflow.",
"tags": [
"Workflow"
],
"operationId": "listWorkflowJobs",
"responses": {
"200": {
"description": "A paginated sequence of jobs.",
"links": {
"NextWorkflowJobPage": {
"operationId": "listWorkflowJobs",
"parameters": {
"id": "$request.path.id",
"page-token": "$response.body#/next_page_token"
}
}
},
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"items": {
"type": "array",
"items": {
"type": "object",
"properties": {
"canceled_by": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"dependencies": {
"type": "array",
"items": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the job."
},
"description": "A sequence of the unique job IDs for the jobs that this job depends upon in the workflow."
},
"job_number": {
"type": "integer",
"format": "int64",
"description": "The number of the job."
},
"id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the job."
},
"started_at": {
"type": "string",
"format": "date-time",
"description": "The date and time the job started."
},
"name": {
"type": "string",
"description": "The name of the job."
},
"approved_by": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the user."
},
"project_slug": {
"type": "string",
"description": "The project-slug for the job.",
"example": "gh/CircleCI-Public/api-preview-docs"
},
"status": {
"enum": [
"success",
"running",
"not_run",
"failed",
"retried",
"queued",
"not_running",
"infrastructure_fail",
"timedout",
"on_hold",
"terminated-unknown",
"blocked",
"canceled",
"unauthorized"
],
"type": "string",
"description": "The current status of the job."
},
"type": {
"enum": [
"build",
"approval"
],
"type": "string",
"description": "The type of job."
},
"stopped_at": {
"type": "string",
"format": "date-time",
"x-nullable": true,
"description": "The time when the job stopped."
},
"approval_request_id": {
"type": "string",
"format": "uuid",
"description": "The unique ID of the job."
}
},
"required": [
"id",
"name",
"started_at",
"dependencies",
"project_slug",
"status",
"type"
],
"description": "Job",
"title": "Job"
}
},
"next_page_token": {
"type": "string",
"x-nullable": true,
"description": "A token to pass as a `page-token` query parameter to return the next page of results."
}
},
"required": [
"items",
"next_page_token"
],
"title": "WorkflowJobListResponse"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The unique ID of the workflow.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/job',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/job\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/job\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/job \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/workflow/{id}/rerun": {
"post": {
"summary": "Rerun a workflow",
"description": "Reruns a workflow.",
"tags": [
"Workflow"
],
"operationId": "rerunWorkflow",
"responses": {
"202": {
"description": "A confirmation message.",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"workflow_id": {
"type": "string",
"format": "uuid",
"description": "The ID of the newly-created workflow.",
"example": "0e53027b-521a-4c40-9042-47e72b3c63a3"
}
},
"required": [
"workflow_id"
],
"description": "A response to rerunning a workflow"
}
}
}
},
"default": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"message": {
"type": "string"
}
}
}
}
},
"description": "Error response."
}
},
"parameters": [
{
"in": "path",
"name": "id",
"description": "The unique ID of the workflow.",
"schema": {
"type": "string",
"format": "uuid"
},
"required": true,
"example": "5034460f-c7c4-4c43-9457-de07e2029e7b"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"enable_ssh": {
"type": "boolean",
"description": "Whether to enable SSH access for the triggering user on the newly-rerun job. Requires the jobs parameter to be used and so is mutually exclusive with the from_failed parameter.",
"example": false
},
"from_failed": {
"type": "boolean",
"description": "Whether to rerun the workflow from the failed job. Mutually exclusive with the jobs parameter.",
"example": false
},
"jobs": {
"type": "array",
"items": {
"type": "string",
"format": "uuid"
},
"description": "A list of job IDs to rerun.",
"example": [
"c65b68ef-e73b-4bf2-be9a-7a322a9df150",
"5e957edd-5e8c-4985-9178-5d0d69561822"
]
},
"sparse_tree": {
"type": "boolean",
"description": "Completes rerun using sparse trees logic, an optimization for workflows that have disconnected subgraphs. Requires jobs parameter and so is mutually exclusive with the from_failed parameter.",
"example": false
}
},
"x-nullable": true,
"description": "The information you can supply when rerunning a workflow.",
"title": "RerunWorkflowParameters"
}
}
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/rerun',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n enable_ssh: false,\n from_failed: false,\n jobs: ['c65b68ef-e73b-4bf2-be9a-7a322a9df150', '5e957edd-5e8c-4985-9178-5d0d69561822'],\n sparse_tree: false\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"enable_ssh\\\":false,\\\"from_failed\\\":false,\\\"jobs\\\":[\\\"c65b68ef-e73b-4bf2-be9a-7a322a9df150\\\",\\\"5e957edd-5e8c-4985-9178-5d0d69561822\\\"],\\\"sparse_tree\\\":false}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/rerun\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/rerun\"\n\n\tpayload := strings.NewReader(\"{\\\"enable_ssh\\\":false,\\\"from_failed\\\":false,\\\"jobs\\\":[\\\"c65b68ef-e73b-4bf2-be9a-7a322a9df150\\\",\\\"5e957edd-5e8c-4985-9178-5d0d69561822\\\"],\\\"sparse_tree\\\":false}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/workflow/5034460f-c7c4-4c43-9457-de07e2029e7b/rerun \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"enable_ssh\":false,\"from_failed\":false,\"jobs\":[\"c65b68ef-e73b-4bf2-be9a-7a322a9df150\",\"5e957edd-5e8c-4985-9178-5d0d69561822\"],\"sparse_tree\":false}'"
}
]
}
},
"/org/{orgID}/oidc-custom-claims": {
"delete": {
"description": "Deletes org-level custom claims of OIDC identity tokens",
"operationId": "DeleteOrgClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
},
{
"$ref": "#/components/parameters/Claims"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully deleted."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Delete org-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims',\n qs: {claims: 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/org/%7BorgID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url 'https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"description": "Fetches org-level custom claims of OIDC identity tokens",
"operationId": "GetOrgClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully fetched."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Get org-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/org/%7BorgID%7D/oidc-custom-claims\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"patch": {
"description": "Creates/Updates org-level custom claims of OIDC identity tokens",
"operationId": "PatchOrgClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PatchClaimsRequest"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully patched."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Patch org-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PATCH',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {audience: ['string'], ttl: 'string'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"audience\\\":[\\\"string\\\"],\\\"ttl\\\":\\\"string\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PATCH\", \"/api/v2/org/%7BorgID%7D/oidc-custom-claims\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims\"\n\n\tpayload := strings.NewReader(\"{\\\"audience\\\":[\\\"string\\\"],\\\"ttl\\\":\\\"string\\\"}\")\n\n\treq, _ := http.NewRequest(\"PATCH\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PATCH \\\n --url https://circleci.com/api/v2/org/%7BorgID%7D/oidc-custom-claims \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"audience\":[\"string\"],\"ttl\":\"string\"}'"
}
]
}
},
"/org/{orgID}/project/{projectID}/oidc-custom-claims": {
"delete": {
"description": "Deletes project-level custom claims of OIDC identity tokens",
"operationId": "DeleteProjectClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
},
{
"$ref": "#/components/parameters/ProjectID"
},
{
"$ref": "#/components/parameters/Claims"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully deleted."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Delete project-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims',\n qs: {claims: 'SOME_STRING_VALUE'},\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url 'https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims?claims=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"get": {
"description": "Fetches project-level custom claims of OIDC identity tokens",
"operationId": "GetProjectClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
},
{
"$ref": "#/components/parameters/ProjectID"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully fetched."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Get project-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"patch": {
"description": "Creates/Updates project-level custom claims of OIDC identity tokens",
"operationId": "PatchProjectClaims",
"parameters": [
{
"$ref": "#/components/parameters/OrgID"
},
{
"$ref": "#/components/parameters/ProjectID"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PatchClaimsRequest"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ClaimResponse"
}
}
},
"description": "Claims successfully patched."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/InternalServerError"
}
},
"summary": "Patch project-level claims",
"tags": [
"OIDC Token Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PATCH',\n url: 'https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {audience: ['string'], ttl: 'string'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"audience\\\":[\\\"string\\\"],\\\"ttl\\\":\\\"string\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PATCH\", \"/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims\"\n\n\tpayload := strings.NewReader(\"{\\\"audience\\\":[\\\"string\\\"],\\\"ttl\\\":\\\"string\\\"}\")\n\n\treq, _ := http.NewRequest(\"PATCH\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PATCH \\\n --url https://circleci.com/api/v2/org/%7BorgID%7D/project/%7BprojectID%7D/oidc-custom-claims \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"audience\":[\"string\"],\"ttl\":\"string\"}'"
}
]
}
},
"/owner/{ownerID}/context/{context}/decision": {
"get": {
"description": "This endpoint will return a list of decision audit logs that were made using this owner's policies.",
"operationId": "GetDecisionLogs",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
},
{
"description": "Return decisions matching this decision status.",
"in": "query",
"name": "status",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Return decisions made after this date.",
"in": "query",
"name": "after",
"required": false,
"schema": {
"format": "date-time",
"type": "string"
}
},
{
"description": "Return decisions made before this date.",
"in": "query",
"name": "before",
"required": false,
"schema": {
"format": "date-time",
"type": "string"
}
},
{
"description": "Return decisions made on this branch.",
"in": "query",
"name": "branch",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Return decisions made for this project.",
"in": "query",
"name": "project_id",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Return decisions made for this build number.",
"in": "query",
"name": "build_number",
"required": false,
"schema": {
"type": "string"
}
},
{
"description": "Sets the offset when retrieving the decisions, for paging.",
"in": "query",
"name": "offset",
"required": false,
"schema": {
"type": "integer"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"items": {
"$ref": "#/components/schemas/DecisionLog"
},
"type": "array"
}
}
},
"description": "Decision logs successfully retrieved."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Retrieves the owner's decision audit logs.",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision',\n qs: {\n status: 'SOME_STRING_VALUE',\n after: 'SOME_STRING_VALUE',\n before: 'SOME_STRING_VALUE',\n branch: 'SOME_STRING_VALUE',\n project_id: 'SOME_STRING_VALUE',\n build_number: 'SOME_STRING_VALUE',\n offset: 'SOME_INTEGER_VALUE'\n },\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision?status=SOME_STRING_VALUE&after=SOME_STRING_VALUE&before=SOME_STRING_VALUE&branch=SOME_STRING_VALUE&project_id=SOME_STRING_VALUE&build_number=SOME_STRING_VALUE&offset=SOME_INTEGER_VALUE\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision?status=SOME_STRING_VALUE&after=SOME_STRING_VALUE&before=SOME_STRING_VALUE&branch=SOME_STRING_VALUE&project_id=SOME_STRING_VALUE&build_number=SOME_STRING_VALUE&offset=SOME_INTEGER_VALUE\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision?status=SOME_STRING_VALUE&after=SOME_STRING_VALUE&before=SOME_STRING_VALUE&branch=SOME_STRING_VALUE&project_id=SOME_STRING_VALUE&build_number=SOME_STRING_VALUE&offset=SOME_INTEGER_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"post": {
"description": "This endpoint will evaluate input data (config+metadata) against owner's stored policies and return a decision.",
"operationId": "MakeDecision",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"properties": {
"input": {
"type": "string"
},
"metadata": {
"type": "object"
}
},
"required": [
"input"
],
"type": "object"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Decision"
}
}
},
"description": "Decision rendered by applying the policy against the provided data. Response will be modeled by the data and rego processed."
},
"400": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "context: must be a valid value.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request is malformed\n"
},
"401": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "Unauthorized.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request is unauthorized\n"
},
"500": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "There was an error processing your request.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "Something unexpected happened on the server."
}
},
"summary": "Makes a decision",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {input: 'string', metadata: {}},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"input\\\":\\\"string\\\",\\\"metadata\\\":{}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision\"\n\n\tpayload := strings.NewReader(\"{\\\"input\\\":\\\"string\\\",\\\"metadata\\\":{}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"input\":\"string\",\"metadata\":{}}'"
}
]
}
},
"/owner/{ownerID}/context/{context}/decision/settings": {
"get": {
"description": "This endpoint retrieves the current decision settings (eg enable/disable policy evaluation)",
"operationId": "GetDecisionSettings",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecisionSettings"
}
}
},
"description": "Decision settings successfully retrieved."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Get the decision settings",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"patch": {
"description": "This endpoint allows modifying decision settings (eg enable/disable policy evaluation)",
"operationId": "SetDecisionSettings",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecisionSettings"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecisionSettings"
}
}
},
"description": "Decision settings successfully set."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Set the decision settings",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PATCH',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {enabled: true},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"enabled\\\":true}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PATCH\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings\"\n\n\tpayload := strings.NewReader(\"{\\\"enabled\\\":true}\")\n\n\treq, _ := http.NewRequest(\"PATCH\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PATCH \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/settings \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"enabled\":true}'"
}
]
}
},
"/owner/{ownerID}/context/{context}/decision/{decisionID}": {
"get": {
"description": "This endpoint will retrieve a decision for a given decision log ID",
"operationId": "GetDecisionLog",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
},
{
"$ref": "#/components/parameters/DecisionID"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DecisionLog"
}
}
},
"description": "Decision log successfully retrieved."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "decision log not found",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "There was no decision log found for given decision_id, and owner_id.\n"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Retrieves the owner's decision audit log by given decisionID",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/owner/{ownerID}/context/{context}/decision/{decisionID}/policy-bundle": {
"get": {
"description": "This endpoint will retrieve a policy bundle for a given decision log ID",
"operationId": "GetDecisionLogPolicyBundle",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
},
{
"$ref": "#/components/parameters/DecisionID"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PolicyBundle"
}
}
},
"description": "Policy-Bundle retrieved successfully for given decision log ID"
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "decision log not found",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "There was no decision log found for given decision_id, and owner_id.\n"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Retrieves Policy Bundle for a given decision log ID",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D/policy-bundle',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D/policy-bundle\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D/policy-bundle\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/decision/%7BdecisionID%7D/policy-bundle \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/owner/{ownerID}/context/{context}/policy-bundle": {
"get": {
"description": "This endpoint will retrieve a policy bundle",
"operationId": "GetPolicyBundle",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PolicyBundle"
}
}
},
"description": "Policy-Bundle retrieved successfully."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Retrieves Policy Bundle",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"post": {
"description": "This endpoint replaces the current policy bundle with the provided policy bundle",
"operationId": "CreatePolicyBundle",
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
},
{
"in": "query",
"name": "dry",
"schema": {
"type": "boolean"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BundlePayload"
}
}
}
},
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BundleDiff"
}
}
},
"description": "Policy-Bundle diff successfully returned."
},
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/BundleDiff"
}
}
},
"description": "Policy-Bundle successfully created."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"413": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "http: request payload too large",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request exceeds the maximum payload size for policy bundles ~2.5Mib\n"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Creates policy bundle for the context",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle',\n qs: {dry: 'SOME_BOOLEAN_VALUE'},\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {policies: {property1: 'string', property2: 'string'}},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"policies\\\":{\\\"property1\\\":\\\"string\\\",\\\"property2\\\":\\\"string\\\"}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle?dry=SOME_BOOLEAN_VALUE\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle?dry=SOME_BOOLEAN_VALUE\"\n\n\tpayload := strings.NewReader(\"{\\\"policies\\\":{\\\"property1\\\":\\\"string\\\",\\\"property2\\\":\\\"string\\\"}}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle?dry=SOME_BOOLEAN_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"policies\":{\"property1\":\"string\",\"property2\":\"string\"}}'"
}
]
}
},
"/owner/{ownerID}/context/{context}/policy-bundle/{policyName}": {
"get": {
"description": "This endpoint will retrieve a policy document.",
"operationId": "GetPolicyDocument",
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Policy"
}
}
},
"description": "Policy retrieved successfully."
},
"400": {
"$ref": "#/components/responses/BadRequest"
},
"401": {
"$ref": "#/components/responses/Unauthorized"
},
"403": {
"$ref": "#/components/responses/Forbidden"
},
"404": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "policy not found",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "There was no policy that was found with the given owner_id and policy name.\n"
},
"500": {
"$ref": "#/components/responses/UnexpectedServerError"
}
},
"summary": "Retrieves a policy document",
"tags": [
"Policy Management"
],
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle/%7BpolicyName%7D',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle/%7BpolicyName%7D\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle/%7BpolicyName%7D\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/owner/%7BownerID%7D/context/%7Bcontext%7D/policy-bundle/%7BpolicyName%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"parameters": [
{
"$ref": "#/components/parameters/OwnerID"
},
{
"$ref": "#/components/parameters/Context"
},
{
"description": "the policy name set by the rego policy_name rule",
"in": "path",
"name": "policyName",
"required": true,
"schema": {
"type": "string"
}
}
]
},
"/context/{context_id}/restrictions": {
"parameters": [
{
"$ref": "#/components/parameters/context_id"
}
],
"get": {
"operationId": "getContextRestrictions",
"summary": "🧪 Get context restrictions",
"description": "[__EXPERIMENTAL__] Gets a list of project restrictions associated with a context.",
"tags": [
"Context"
],
"responses": {
"200": {
"description": "Successful response.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/context_project_restrictions_list"
}
}
}
},
"400": {
"$ref": "#/components/responses/400_invalid_context_id"
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"404": {
"$ref": "#/components/responses/404_entity_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"post": {
"operationId": "createContextRestriction",
"summary": "🧪 Create context restriction",
"description": "[__EXPERIMENTAL__] Creates project restriction on a context.",
"tags": [
"Context"
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"type": "object",
"additionalProperties": false,
"properties": {
"project_id": {
"type": "string",
"format": "uuid",
"deprecated": true,
"description": "Deprecated - Use \"restriction_type\" and \"restriction_value\"\ninstead.\n\nThe project ID to use for a project restriction. This is\nmutually exclusive with restriction_type and restriction_value\nand implies restriction_type is \"project\".\n"
},
"restriction_type": {
"type": "string"
},
"restriction_value": {
"type": "string"
}
}
},
"example": {
"project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9",
"restriction_type": "project",
"restriction_value": "405d8375-3514-403b-8c43-83ae74cfe0e9"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Successful response.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/restriction_created"
}
}
}
},
"400": {
"description": "Bad request.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"invalid_restriction": {
"summary": "Invalid restriction",
"value": {
"message": "This restriction cannot be applied to this context."
}
},
"invalid_access": {
"summary": "Project doesn't exist, or insufficient credentials",
"value": {
"message": "Project does not exist, or user does not have access to this project."
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"404": {
"$ref": "#/components/responses/404_entity_not_found"
},
"409": {
"description": "Request conflict.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"restriction_conflict": {
"summary": "Restriction conflict",
"value": {
"message": "The restriction you're trying to add already exists."
}
}
}
}
}
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {project_id: 'string', restriction_type: 'string', restriction_value: 'string'},\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"project_id\\\":\\\"string\\\",\\\"restriction_type\\\":\\\"string\\\",\\\"restriction_value\\\":\\\"string\\\"}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions\"\n\n\tpayload := strings.NewReader(\"{\\\"project_id\\\":\\\"string\\\",\\\"restriction_type\\\":\\\"string\\\",\\\"restriction_value\\\":\\\"string\\\"}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"project_id\":\"string\",\"restriction_type\":\"string\",\"restriction_value\":\"string\"}'"
}
]
}
},
"/context/{context_id}/restrictions/{restriction_id}": {
"parameters": [
{
"$ref": "#/components/parameters/context_id"
},
{
"$ref": "#/components/parameters/restriction_id"
}
],
"delete": {
"operationId": "deleteContextRestriction",
"summary": "🧪 Delete context restriction",
"description": "[__EXPERIMENTAL__] Deletes a project restriction on a context.",
"tags": [
"Context"
],
"responses": {
"200": {
"description": "Successful response.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/restriction_deleted"
},
"examples": {
"successful_delete": {
"summary": "Successful deletion of restriction",
"value": {
"message": "Context restriction deleted."
}
}
}
}
}
},
"400": {
"$ref": "#/components/responses/400_invalid_restriction_id"
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"404": {
"$ref": "#/components/responses/404_entity_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'DELETE',\n url: 'https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions/1c23d2cb-07b1-4a28-8af3-e369732050ed',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"DELETE\", \"/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions/1c23d2cb-07b1-4a28-8af3-e369732050ed\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions/1c23d2cb-07b1-4a28-8af3-e369732050ed\"\n\n\treq, _ := http.NewRequest(\"DELETE\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request DELETE \\\n --url https://circleci.com/api/v2/context/be8bb2e3-c3d6-4098-89f4-572ff976ba9a/restrictions/1c23d2cb-07b1-4a28-8af3-e369732050ed \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{provider}/{organization}/{project}": {
"parameters": [
{
"$ref": "#/components/parameters/provider"
},
{
"$ref": "#/components/parameters/organization"
},
{
"$ref": "#/components/parameters/project"
}
],
"post": {
"operationId": "createProject",
"summary": "🧪 Create a project",
"description": "[__EXPERIMENTAL__] Creates a new CircleCI project, and returns a list of the default advanced settings. Can only be called on a repo with a main branch and an existing config.yml file. Not yet available to projects that use GitLab or GitHub App.",
"tags": [
"Project"
],
"responses": {
"201": {
"description": "Successful response.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/project_settings"
}
}
}
},
"400": {
"$ref": "#/components/responses/400_unexpected_request_body"
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"403": {
"$ref": "#/components/responses/403_permission_denied"
},
"404": {
"description": "Either a branch or a project were not found.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"branch_not_found": {
"summary": "Branch not found, unable to trigger pipeline.",
"value": {
"message": "Branch not found."
}
},
"project_not_found": {
"summary": "Project not found, e.g. GitHub repo.",
"value": {
"message": "Project not found."
}
}
}
}
}
},
"405": {
"$ref": "#/components/responses/405_cannot_create_standalone_project"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"POST\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs\"\n\n\treq, _ := http.NewRequest(\"POST\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
},
"/project/{provider}/{organization}/{project}/settings": {
"parameters": [
{
"$ref": "#/components/parameters/provider"
},
{
"$ref": "#/components/parameters/organization"
},
{
"$ref": "#/components/parameters/project"
}
],
"get": {
"operationId": "getProjectSettings",
"summary": "🧪 Get project settings",
"description": "[__EXPERIMENTAL__] Returns a list of the advanced settings for a CircleCI project, whether enabled (true) or not (false).",
"tags": [
"Project"
],
"responses": {
"200": {
"description": "Successful response.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/project_settings"
}
}
}
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"403": {
"$ref": "#/components/responses/403_permission_denied"
},
"404": {
"$ref": "#/components/responses/404_project_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
},
"patch": {
"operationId": "patchProjectSettings",
"summary": "🧪 Update project settings",
"description": "[__EXPERIMENTAL__] Updates one or more of the advanced settings for a CircleCI project.",
"tags": [
"Project"
],
"requestBody": {
"description": "The setting(s) to update, including one or more fields in the JSON object. Note that `oss: true` will only be set on projects whose underlying repositories are actually open source.",
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/project_settings"
},
"example": {
"advanced": {
"autocancel_builds": false,
"build_prs_only": true,
"pr_only_branch_overrides": [
"main"
]
}
}
}
}
},
"responses": {
"200": {
"description": "Successful response. Always includes the full advanced settings object. Returned even when the provided updates match the existing settings, but can also be returned when `oss: true` fails to set.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/project_settings"
}
}
}
},
"400": {
"description": "Request is malformed, e.g. with improperly encoded JSON",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"invalid_json": {
"summary": "Invalid JSON body",
"value": {
"message": "Invalid JSON body."
}
},
"too_many_branch_overrides": {
"summary": "More than 100 branches sent for `pr_only_branch_overrides`",
"value": {
"message": "Field 'pr_only_branch_overrides' only supports up to 100 branches."
}
},
"no_json": {
"summary": "Empty JSON request body",
"value": {
"message": "No JSON fields found."
}
},
"unexpected_field": {
"summary": "Incorrect root field name",
"value": {
"message": "Unexpected JSON field 'incorrect'"
}
},
"unknown_setting": {
"summary": "Incorrect setting name",
"value": {
"message": "Unknown advanced setting 'incorrect'."
}
},
"incorrect_type": {
"summary": "Incorrect setting type",
"value": {
"message": "Setting 'autocancel_builds' must be boolean."
}
},
"oss": {
"summary": "Incorrect OSS value for project",
"value": {
"message": "Feature flag 'oss' is not settable for this project."
}
}
}
}
}
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"403": {
"$ref": "#/components/responses/403_permission_denied"
},
"404": {
"$ref": "#/components/responses/404_project_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'PATCH',\n url: 'https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n advanced: {\n autocancel_builds: true,\n build_fork_prs: true,\n build_prs_only: true,\n disable_ssh: true,\n forks_receive_secret_env_vars: true,\n oss: true,\n set_github_status: true,\n setup_workflows: true,\n write_settings_requires_admin: true,\n pr_only_branch_overrides: ['string']\n }\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"advanced\\\":{\\\"autocancel_builds\\\":true,\\\"build_fork_prs\\\":true,\\\"build_prs_only\\\":true,\\\"disable_ssh\\\":true,\\\"forks_receive_secret_env_vars\\\":true,\\\"oss\\\":true,\\\"set_github_status\\\":true,\\\"setup_workflows\\\":true,\\\"write_settings_requires_admin\\\":true,\\\"pr_only_branch_overrides\\\":[\\\"string\\\"]}}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"PATCH\", \"/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings\"\n\n\tpayload := strings.NewReader(\"{\\\"advanced\\\":{\\\"autocancel_builds\\\":true,\\\"build_fork_prs\\\":true,\\\"build_prs_only\\\":true,\\\"disable_ssh\\\":true,\\\"forks_receive_secret_env_vars\\\":true,\\\"oss\\\":true,\\\"set_github_status\\\":true,\\\"setup_workflows\\\":true,\\\"write_settings_requires_admin\\\":true,\\\"pr_only_branch_overrides\\\":[\\\"string\\\"]}}\")\n\n\treq, _ := http.NewRequest(\"PATCH\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request PATCH \\\n --url https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/settings \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"advanced\":{\"autocancel_builds\":true,\"build_fork_prs\":true,\"build_prs_only\":true,\"disable_ssh\":true,\"forks_receive_secret_env_vars\":true,\"oss\":true,\"set_github_status\":true,\"setup_workflows\":true,\"write_settings_requires_admin\":true,\"pr_only_branch_overrides\":[\"string\"]}}'"
}
]
}
},
"/organizations/{org_id}/usage_export_job": {
"parameters": [
{
"$ref": "#/components/parameters/org_id"
}
],
"post": {
"operationId": "createUsageExport",
"summary": "Create a usage export",
"description": "Submits a request to create a usage export for an organization.",
"tags": [
"Usage"
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"type": "object",
"properties": {
"start": {
"type": "string",
"format": "date-time",
"description": "The start date & time (inclusive) of the range from which data will be pulled. Must be no more than one year ago."
},
"end": {
"type": "string",
"format": "date-time",
"description": "The end date & time (inclusive) of the range from which data will be pulled. Must be no more than 31 days after `start`."
},
"shared_org_ids": {
"type": "array",
"items": {
"type": "string",
"format": "uuid",
"description": "Additional shared org IDs to to include data for in the generated usage export."
}
}
},
"required": [
"start",
"end"
]
}
}
}
},
"responses": {
"201": {
"description": "Usage export created successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/usage_export_job"
}
}
}
},
"400": {
"$ref": "#/components/responses/400_unexpected_request_body"
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"404": {
"$ref": "#/components/responses/404_entity_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job',\n headers: {'content-type': 'application/json', authorization: 'Basic REPLACE_BASIC_AUTH'},\n body: {\n start: '2024-04-30T23:36:42Z',\n end: '2024-04-30T23:36:42Z',\n shared_org_ids: ['string']\n },\n json: true\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\npayload = \"{\\\"start\\\":\\\"2024-04-30T23:36:42Z\\\",\\\"end\\\":\\\"2024-04-30T23:36:42Z\\\",\\\"shared_org_ids\\\":[\\\"string\\\"]}\"\n\nheaders = {\n 'content-type': \"application/json\",\n 'authorization': \"Basic REPLACE_BASIC_AUTH\"\n }\n\nconn.request(\"POST\", \"/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job\", payload, headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"strings\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job\"\n\n\tpayload := strings.NewReader(\"{\\\"start\\\":\\\"2024-04-30T23:36:42Z\\\",\\\"end\\\":\\\"2024-04-30T23:36:42Z\\\",\\\"shared_org_ids\\\":[\\\"string\\\"]}\")\n\n\treq, _ := http.NewRequest(\"POST\", url, payload)\n\n\treq.Header.Add(\"content-type\", \"application/json\")\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request POST \\\n --url https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH' \\\n --header 'content-type: application/json' \\\n --data '{\"start\":\"2024-04-30T23:36:42Z\",\"end\":\"2024-04-30T23:36:42Z\",\"shared_org_ids\":[\"string\"]}'"
}
]
}
},
"/organizations/{org_id}/usage_export_job/{usage_export_job_id}": {
"parameters": [
{
"$ref": "#/components/parameters/org_id"
},
{
"$ref": "#/components/parameters/usage_export_job_id"
}
],
"get": {
"operationId": "getUsageExport",
"summary": "Get a usage export",
"description": "Gets a usage export for an organization.",
"tags": [
"Usage"
],
"responses": {
"200": {
"description": "Usage export fetched successfully",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/get_usage_export_job_status"
}
}
}
},
"400": {
"$ref": "#/components/responses/400_unexpected_request_body"
},
"401": {
"$ref": "#/components/responses/401_invalid_token"
},
"404": {
"$ref": "#/components/responses/404_entity_not_found"
},
"429": {
"$ref": "#/components/responses/429_rate_limit_exceeded"
},
"500": {
"$ref": "#/components/responses/500_internal_server_error"
}
},
"x-codeSamples": [
{
"lang": "Node + Request",
"source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job/e8235eed-f121-4ae3-9c72-2719d6572818',\n headers: {authorization: 'Basic REPLACE_BASIC_AUTH'}\n};\n\nrequest(options, function (error, response, body) {\n if (error) throw new Error(error);\n\n console.log(body);\n});\n"
},
{
"lang": "Python + Python3",
"source": "import http.client\n\nconn = http.client.HTTPSConnection(\"circleci.com\")\n\nheaders = { 'authorization': \"Basic REPLACE_BASIC_AUTH\" }\n\nconn.request(\"GET\", \"/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job/e8235eed-f121-4ae3-9c72-2719d6572818\", headers=headers)\n\nres = conn.getresponse()\ndata = res.read()\n\nprint(data.decode(\"utf-8\"))"
},
{
"lang": "Go + Native",
"source": "package main\n\nimport (\n\t\"fmt\"\n\t\"net/http\"\n\t\"io/ioutil\"\n)\n\nfunc main() {\n\n\turl := \"https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job/e8235eed-f121-4ae3-9c72-2719d6572818\"\n\n\treq, _ := http.NewRequest(\"GET\", url, nil)\n\n\treq.Header.Add(\"authorization\", \"Basic REPLACE_BASIC_AUTH\")\n\n\tres, _ := http.DefaultClient.Do(req)\n\n\tdefer res.Body.Close()\n\tbody, _ := ioutil.ReadAll(res.Body)\n\n\tfmt.Println(res)\n\tfmt.Println(string(body))\n\n}"
},
{
"lang": "Shell + Curl",
"source": "curl --request GET \\\n --url https://circleci.com/api/v2/organizations/b9291e0d-a11e-41fb-8517-c545388b5953/usage_export_job/e8235eed-f121-4ae3-9c72-2719d6572818 \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'"
}
]
}
}
},
"components": {
"securitySchemes": {
"api_key_header": {
"type": "apiKey",
"name": "Circle-Token",
"in": "header",
"description": "Project API tokens are not supported for API v2. Use a personal API token."
},
"basic_auth": {
"description": "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.",
"type": "http",
"scheme": "basic"
},
"api_key_query": {
"type": "apiKey",
"name": "circle-token",
"in": "query",
"description": "DEPRECATED - we will remove this option in the future. Project API tokens are not supported for API v2. Use a personal API token."
}
},
"schemas": {
"ClaimResponse": {
"properties": {
"audience": {
"items": {
"type": "string"
},
"type": "array"
},
"audience_updated_at": {
"format": "date-time",
"type": "string"
},
"org_id": {
"format": "uuid",
"type": "string"
},
"project_id": {
"format": "uuid",
"type": "string"
},
"ttl": {
"$ref": "#/components/schemas/JSONDuration"
},
"ttl_updated_at": {
"format": "date-time",
"type": "string"
}
},
"required": [
"org_id"
],
"type": "object"
},
"JSONDuration": {
"pattern": "^([0-9]+(ms|s|m|h|d|w)){1,7}$",
"type": "string"
},
"PatchClaimsRequest": {
"properties": {
"audience": {
"items": {
"type": "string"
},
"type": "array"
},
"ttl": {
"$ref": "#/components/schemas/JSONDuration"
}
},
"type": "object"
},
"BundleDiff": {
"properties": {
"created": {
"items": {
"description": "policy names",
"type": "string"
},
"type": "array"
},
"deleted": {
"items": {
"description": "policy names",
"type": "string"
},
"type": "array"
},
"modified": {
"items": {
"description": "policy names",
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"BundlePayload": {
"properties": {
"policies": {
"additionalProperties": {
"description": "policy content",
"type": "string"
},
"type": "object"
}
},
"type": "object"
},
"Decision": {
"properties": {
"enabled_rules": {
"items": {
"type": "string"
},
"type": "array"
},
"hard_failures": {
"items": {
"$ref": "#/components/schemas/Violation"
},
"type": "array"
},
"reason": {
"type": "string"
},
"soft_failures": {
"items": {
"$ref": "#/components/schemas/Violation"
},
"type": "array"
},
"status": {
"type": "string"
}
},
"required": [
"status"
],
"type": "object"
},
"DecisionLog": {
"properties": {
"created_at": {
"format": "date-time",
"type": "string"
},
"decision": {
"$ref": "#/components/schemas/Decision"
},
"id": {
"format": "uuid",
"type": "string"
},
"metadata": {
"properties": {
"build_number": {
"type": "integer"
},
"project_id": {
"format": "uuid",
"type": "string"
},
"ssh_rerun": {
"type": "boolean"
},
"vcs": {
"properties": {
"branch": {
"type": "string"
},
"origin_repository_url": {
"type": "string"
},
"release_tag": {
"type": "string"
},
"target_repository_url": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"policies": {
"additionalProperties": {
"maxLength": 128,
"minLength": 128,
"type": "string"
},
"description": "policy-name-to-hash-map",
"example": {
"policy_name1": "1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75",
"policy_name2": "5267768822ee624d48fce15ec5ca79cbd602cb7f4c2157a516556991f22ef8c7b5ef7b18d1ff41c59370efb0858651d44a936c11b7b144c48fe04df3c6a3e8da"
},
"type": "object"
},
"time_taken_ms": {
"type": "integer"
}
},
"type": "object"
},
"DecisionSettings": {
"properties": {
"enabled": {
"type": "boolean"
}
},
"type": "object"
},
"Policy": {
"properties": {
"content": {
"type": "string"
},
"created_at": {
"format": "date-time",
"type": "string"
},
"created_by": {
"type": "string"
},
"name": {
"type": "string"
}
},
"type": "object"
},
"PolicyBundle": {
"additionalProperties": {
"items": {
"$ref": "#/components/schemas/Policy"
}
},
"type": "object"
},
"Violation": {
"properties": {
"reason": {
"type": "string"
},
"rule": {
"type": "string"
}
},
"required": [
"rule",
"reason"
],
"type": "object"
},
"context_project_restrictions_list": {
"type": "object",
"additionalProperties": false,
"properties": {
"items": {
"type": "array",
"items": {
"additionalProperties": false,
"properties": {
"context_id": {
"type": "string",
"format": "uuid",
"description": "UUID of the context"
},
"id": {
"type": "string",
"format": "uuid",
"description": "UUID of the restriction"
},
"project_id": {
"type": "string",
"format": "uuid",
"description": "Deprecated - For \"project\" restrictions read the project ID from\n\"restriction_value\" instead.\n\nUUID of the project used in a project restriction.\n",
"deprecated": true
},
"name": {
"type": "string",
"description": "Contains a human-readable reference for the restriction. For\n\"project\" restrictions this is the name of the project.\n\nMay be null.\n"
},
"restriction_type": {
"type": "string",
"description": "Type of the restriction",
"enum": [
"project",
"expression"
]
},
"restriction_value": {
"type": "string",
"description": "Value used to evaluate the restriction"
}
}
}
},
"next_page_token": {
"type": "string",
"nullable": true,
"description": "Token that can be used to retrieve next page of results"
}
}
},
"project_settings": {
"type": "object",
"additionalProperties": false,
"properties": {
"advanced": {
"type": "object",
"additionalProperties": false,
"properties": {
"autocancel_builds": {
"type": "boolean",
"description": "Except for the default branch, cancel running pipelines on a branch when a new pipeline starts on that branch."
},
"build_fork_prs": {
"type": "boolean",
"description": "Run builds for pull requests from forks."
},
"build_prs_only": {
"type": "boolean",
"description": "Once enabled, we will only build branches that have associated pull requests open."
},
"disable_ssh": {
"type": "boolean",
"description": "When set to true, job re-runs with SSH debugging access will be disabled for the project."
},
"forks_receive_secret_env_vars": {
"type": "boolean",
"description": "Run builds for forked pull requests with this project's configuration, environment variables, and secrets."
},
"oss": {
"type": "boolean",
"description": "Free and Open Source. Enabling this grants additional credits, and lets others see your builds, both through the web UI and the API."
},
"set_github_status": {
"type": "boolean",
"description": "Report the status of every pushed commit to GitHub's status API. Updates reported per job."
},
"setup_workflows": {
"type": "boolean",
"description": "Enabling allows you to conditionally trigger configurations outside of the primary `.circleci` parent directory."
},
"write_settings_requires_admin": {
"type": "boolean",
"description": "Whether updating these settings requires a user to be an organization administrator. When disabled, updating settings can be done by any member."
},
"pr_only_branch_overrides": {
"type": "array",
"items": {
"type": "string"
},
"description": "This field is used in conjunction with the `build_prs_only`, it allows you to specify a list of branches that will always triger a build. The value passed will overwrite the existing value."
}
}
}
}
},
"restriction_created": {
"additionalProperties": false,
"properties": {
"id": {
"type": "string",
"format": "uuid",
"description": "UUID of the project restriction"
},
"project_id": {
"type": "string",
"format": "uuid",
"description": "Deprecated - For \"project\" restrictions read the project ID from\n\"restriction_value\" instead.\n\nUUID of the project used in a project restriction.\n"
},
"name": {
"type": "string",
"description": "Contains a human-readable reference for the restriction. For\n\"project\" restrictions this is the name of the project.\n\nMay be null.\n"
},
"restriction_type": {
"type": "string",
"description": "Type of the restriction",
"enum": [
"project",
"expression"
]
},
"restriction_value": {
"type": "string",
"description": "Value used to evaluate the restriction"
}
}
},
"restriction_deleted": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"description": "Response message"
}
}
},
"usage_export_job": {
"type": "object",
"additionalProperties": false,
"properties": {
"usage_export_job_id": {
"type": "string",
"format": "uuid"
},
"state": {
"type": "string",
"enum": [
"created",
"processing",
"failed",
"completed"
]
},
"start": {
"type": "string",
"format": "date-time"
},
"end": {
"type": "string",
"format": "date-time"
},
"download_urls": {
"description": "A list of pre signed urls that the client can use to download the results of a Usage Export.",
"type": "array",
"items": {
"additionalProperties": false,
"type": "string",
"format": "uri"
}
}
},
"required": [
"usage_export_job_id",
"state",
"start",
"end",
"download_urls"
]
},
"get_usage_export_job_status": {
"type": "object",
"additionalProperties": false,
"properties": {
"usage_export_job_id": {
"type": "string",
"format": "uuid"
},
"state": {
"type": "string",
"enum": [
"created",
"processing",
"failed",
"completed"
]
},
"download_urls": {
"description": "A list of pre signed urls that the client can use to download the results of a Usage Export.",
"type": "array",
"items": {
"additionalProperties": false,
"type": "string",
"format": "uri"
}
},
"error_reason": {
"type": "string"
}
},
"required": [
"usage_export_job_id",
"state",
"download_urls"
]
}
},
"responses": {
"BadRequest": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "OwnerID: must be a valid UUID.",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request is malformed (e.g, a given path parameter is invalid)\n"
},
"Forbidden": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "Forbidden",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The user is forbidden from making this request\n"
},
"InternalServerError": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "internal server error",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "Something unexpected happened on the server."
},
"Unauthenticated": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "unauthenticated",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request is unauthenticated\n"
},
"Unauthorized": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "Unauthorized",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "The request is unauthorized\n"
},
"UnexpectedServerError": {
"content": {
"application/json": {
"schema": {
"properties": {
"error": {
"example": "unexpected server error",
"type": "string"
}
},
"required": [
"error"
],
"type": "object"
}
}
},
"description": "Something unexpected happened on the server."
},
"400_invalid_context_id": {
"description": "Context ID provided is invalid.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "context_id is invalid."
}
}
}
}
}
},
"401_invalid_token": {
"description": "Credentials provided are invalid.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"invalid_token": {
"summary": "Token is invalid.",
"value": {
"message": "Invalid token provided."
}
},
"old_token": {
"summary": "Token was generated before 2023-06-23.",
"value": {
"message": "New format tokens are needed to authenticate this API endpoint. Create a new API token for access."
}
},
"query_auth": {
"summary": "Authentication attempted via query parameters.",
"value": {
"message": "Support for query parameter authentication has been deprecated to improve security. Please use a supported authentication method such as header-based, or basic authentication."
}
}
}
}
}
},
"404_entity_not_found": {
"description": "Entity not found.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"context_not_found": {
"summary": "Context not found.",
"value": {
"message": "Context not found."
}
},
"org_not_found": {
"summary": "Organization not found.",
"value": {
"message": "Organization does not exist."
}
},
"user_not_found": {
"summary": "User not found.",
"value": {
"message": "User does not exist."
}
},
"project_not_found": {
"summary": "Project not found.",
"value": {
"message": "Project does not exist."
}
},
"group_not_found": {
"summary": "Group not found.",
"value": {
"message": "Group does not exist."
}
}
}
}
}
},
"429_rate_limit_exceeded": {
"description": "API rate limits exceeded.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Rate limit exceeded."
}
}
}
}
}
},
"500_internal_server_error": {
"description": "Internal server error.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Internal server error."
}
}
}
}
}
},
"400_invalid_restriction_id": {
"description": "Context restriction ID provided is invalid.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "restriction_id is invalid."
}
}
}
}
}
},
"400_unexpected_request_body": {
"description": "Unexpected request body provided.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Unexpected request body provided."
}
}
}
}
}
},
"403_permission_denied": {
"description": "None or insufficient credentials provided.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Permission denied."
}
}
}
}
}
},
"405_cannot_create_standalone_project": {
"description": "Create projects using the API is currently supported for classic Github OAuth and Bitbucket projects only.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Create projects using the API is currently supported for classic Github OAuth and Bitbucket projects only."
}
}
}
}
}
},
"404_project_not_found": {
"description": "Insufficient credentials for a private project, OR the organization, project, or repository does not exist.",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string",
"default": "Project not found."
}
}
}
}
}
},
"409_group_conflict": {
"description": "A conflict has occurred while attempting to create the resource.\n",
"content": {
"application/json": {
"schema": {
"additionalProperties": false,
"properties": {
"message": {
"type": "string"
}
}
},
"examples": {
"max_groups": {
"summary": "Max number of groups reached",
"value": {
"message": "Failed to create group, reached max number of groups for this organization."
}
},
"name_already_taken": {
"summary": "Group name already taken",
"value": {
"message": "Failed to create group, group <group-name> already exists."
}
}
}
}
}
}
},
"parameters": {
"Claims": {
"description": "comma separated list of claims to delete. Valid values are \"audience\" and \"ttl\".",
"in": "query",
"name": "claims",
"required": true,
"schema": {
"type": "string"
}
},
"OrgID": {
"in": "path",
"name": "orgID",
"required": true,
"schema": {
"format": "uuid",
"type": "string"
}
},
"ProjectID": {
"in": "path",
"name": "projectID",
"required": true,
"schema": {
"format": "uuid",
"type": "string"
}
},
"Context": {
"in": "path",
"name": "context",
"required": true,
"schema": {
"type": "string"
}
},
"DecisionID": {
"in": "path",
"name": "decisionID",
"required": true,
"schema": {
"type": "string"
}
},
"OwnerID": {
"in": "path",
"name": "ownerID",
"required": true,
"schema": {
"type": "string"
}
},
"context_id": {
"name": "context_id",
"description": "An opaque identifier of a context.",
"example": "be8bb2e3-c3d6-4098-89f4-572ff976ba9a",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"restriction_id": {
"name": "restriction_id",
"description": "An opaque identifier of a context restriction.",
"example": "1c23d2cb-07b1-4a28-8af3-e369732050ed",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"provider": {
"name": "provider",
"description": "The `provider` segment of a project or org slug, the first of the three. This may be a VCS. For projects that use GitLab or GitHub App, use `circleci`.",
"example": "gh",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"organization": {
"name": "organization",
"description": "The `organization` segment of a project or org slug, the second of the three. For GitHub OAuth or Bitbucket projects, this is the organization name. For projects that use GitLab or GitHub App, use the organization ID (found in Organization Settings).",
"example": "CircleCI-Public",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"project": {
"name": "project",
"description": "The `project` segment of a project slug, the third of the three. For GitHub OAuth or Bitbucket projects, this is the repository name. For projects that use GitLab or GitHub App, use the project ID (found in Project Settings).",
"example": "api-preview-docs",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"org_id": {
"name": "org_id",
"description": "An opaque identifier of an organization.",
"example": "b9291e0d-a11e-41fb-8517-c545388b5953",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"user_id": {
"name": "user_id",
"description": "An opaque identifier of a user.",
"example": "a68942a8-c217-4d92-96e5-3b47f9a2f0d9",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"limit": {
"name": "limit",
"in": "query",
"description": "The number of results per page.",
"schema": {
"type": "integer"
}
},
"next_page_token": {
"name": "next_page_token",
"in": "query",
"description": "Specify what page of results to fetch.",
"schema": {
"type": "string"
}
},
"group_id": {
"name": "group_id",
"description": "An opaque identifier of a group.",
"example": "39f660db-f49b-417e-ad79-2769ba29faf7",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"project_id": {
"name": "project_id",
"description": "An opaque identifier of a project.",
"example": "39723015-b399-4601-9ff6-bd1bfbed8fa8",
"in": "path",
"required": true,
"schema": {
"type": "string"
}
},
"usage_export_job_id": {
"name": "usage_export_job_id",
"description": "An opaque identifier of a usage export job.",
"example": "e8235eed-f121-4ae3-9c72-2719d6572818",
"in": "path",
"required": true,
"schema": {
"type": "string",
"format": "uuid"
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment