{ "openapi": "3.0.0", "info": { "version": "v2", "title": "CircleCI API", "description": "This describes the resources that make up the CircleCI API v2.\n\n# Authentication\n\n", "license": { "name": "MIT" } }, "servers": [ { "url": "https://circleci.com/api/v2" } ], "security": [ { "api_key_header": [] }, { "basic_auth": [] }, { "api_key_query": [] } ], "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: {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?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(\"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?owner-id=c65b68ef-e73b-4bf2-be9a-7a322a9df150&page-token=next_page_token' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "post": { "summary": "Create 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\"}}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"name\\\":\\\"string\\\",\\\"owner\\\":{\\\"id\\\":\\\"string\\\",\\\"type\\\":\\\"organization\\\"}}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/context/{context-id}": { "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context/%7Bcontext-id%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context/%7Bcontext-id%7D\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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" }, "context_id": { "type": "string", "format": "uuid", "description": "ID of the context (UUID)" } }, "required": [ "variable", "created_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 } ], "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 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\", 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\"\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 \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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" }, "context_id": { "type": "string", "format": "uuid", "description": "ID of the context (UUID)" } }, "required": [ "variable", "created_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\"}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Put.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"value\\\":\\\"some-secret-value\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/context/%7Bcontext-id%7D/environment-variable/POSTGRES_USER\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 Metrics are refreshed daily, and thus may not include executions from the last 24 hours. \n Please note that Insights is not a real time financial reporting tool and should not be used for credit reporting. \n The most up to date credit information can be found in Plan Overview 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." }, "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." }, "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." }, "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.", "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/insights/time-series/{project-slug}/workflows": { "get": { "summary": "Workflow timeseries data", "description": "If no query parameters are supplied, will return timeseries data for all workflows that have ran on the default branch. \n \n When granularity is `hourly`, up to 48 hours of timeseries data will be returned. When granularity is `daily`, up to 90 days of timeseries data will be returned.\n \n Different combinations of branches and workflow-names can narrow the query further: \n\n * All workflows, default branch (default, no query parameters) \n * All workflows, all branches: `all-branches=true`\n * All workflows on specific branch: `branch=feature-branch`\n * A specified workflow, all branches: `workflow-name=build&all-branches=true`, \n * A specified branch on a specified workflow: `workflow-name=build&branch=feature-branch`", "tags": [ "Insights" ], "operationId": "getWorkflowTimeseries", "responses": { "200": { "description": "An array of timeseries data, one entry per workflow.", "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." }, "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.", "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. 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 }, { "in": "query", "name": "timeseries-granularity", "description": "The granularity for which to query timeseries data.", "schema": { "type": "string", "enum": [ "daily", "hourly" ] }, "required": false, "example": "hourly" }, { "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" }, { "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',\n qs: {\n branch: 'SOME_STRING_VALUE',\n 'all-branches': 'SOME_BOOLEAN_VALUE',\n 'timeseries-granularity': 'SOME_STRING_VALUE',\n 'workflow-name': '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?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE×eries-granularity=SOME_STRING_VALUE&workflow-name=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?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE×eries-granularity=SOME_STRING_VALUE&workflow-name=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?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE×eries-granularity=SOME_STRING_VALUE&workflow-name=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows?branch=SOME_STRING_VALUE&all-branches=SOME_BOOLEAN_VALUE×eries-granularity=SOME_STRING_VALUE&workflow-name=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/insights/time-series/{project-slug}/workflows/{workflow-name}/jobs": { "get": { "summary": "Job timeseries data", "description": "Get timeseries data for all jobs within a workflow.", "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." }, "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.", "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": "timeseries-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 'timeseries-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×eries-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×eries-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×eries-granularity=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/time-series/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs?branch=SOME_STRING_VALUE×eries-granularity=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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." }, "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." }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/gh/CircleCI-Public/summary?reporting-window=SOME_STRING_VALUE&project-names=SOME_OBJECT_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "tags": [ "Insights" ], "operationId": "getAllInsightsBranches", "responses": { "200": { "description": "A list of branches for a project", "content": { "application/json": { "schema": {} } } }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/branches?workflow-name=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 faliled 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": { "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 flaky tests" } }, "required": [ "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/flaky-tests\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 real time financial reporting tool and should not be used for credit reporting. The most up to date credit information can be found in Plan Overview 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" }, "window_start": { "type": "string", "format": "date-time", "description": "The start of the aggregation window for workflow metrics." }, "window_end": { "type": "string", "format": "date-time", "description": "The end of the aggregation window for workflow metrics." }, "metrics": { "type": "object", "properties": { "total_runs": { "type": "integer", "format": "int64", "minimum": 0, "description": "The total number of runs." }, "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": [ "success_rate", "total_runs", "failed_runs", "successful_runs", "throughput", "mttr", "total_recoveries", "total_credits_used", "duration_metrics" ], "description": "Metrics relating to a workflow's runs." } }, "required": [ "name", "window_start", "window_end", "metrics" ] }, "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.", "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 real time financial reporting tool and should not be used for credit reporting. The most up to date credit information can be found in Plan Overview 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." } }, "required": [ "id", "branch", "duration", "created_at", "stopped_at", "credits_used", "status" ] }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 real time financial reporting tool and should not be used for credit reporting. The most up to date credit information can be found in Plan Overview 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." }, "window_start": { "type": "string", "format": "date-time", "description": "The start of the aggregation window for job metrics." }, "window_end": { "type": "string", "format": "date-time", "description": "The end of the aggregation window for job metrics." }, "metrics": { "type": "object", "properties": { "success_rate": { "type": "number", "format": "float" }, "total_runs": { "type": "integer", "format": "int64", "minimum": 0, "description": "The total number of runs." }, "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." }, "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." }, "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." } }, "required": [ "success_rate", "total_runs", "failed_runs", "successful_runs", "throughput", "total_credits_used", "duration_metrics" ], "description": "Metrics relating to a workflow job's runs." } }, "required": [ "name", "window_start", "window_end", "metrics" ] }, "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.", "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/insights/{project-slug}/workflows/{workflow-name}/jobs/{job-name}": { "get": { "summary": "Get recent runs of a workflow job", "description": "Get recent runs of a job within a workflow. Runs going back at most 90 days are returned. Please note that Insights is not a real time financial reporting tool and should not be used for credit reporting. The most up to date credit information can be found in Plan Overview in the CircleCI UI.", "tags": [ "Insights" ], "operationId": "getProjectJobRuns", "responses": { "200": { "description": "A paginated list of recent job 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 job." }, "started_at": { "type": "string", "format": "date-time", "description": "The date and time the job started." }, "stopped_at": { "type": "string", "format": "date-time", "x-nullable": true, "description": "The time when the job stopped." }, "status": { "enum": [ "success", "not_run", "failed", "canceled", "unauthorized" ], "type": "string", "x-nullable": true, "description": "Job status." }, "duration": { "type": "integer", "format": "int64", "minimum": 0, "x-nullable": true, "description": "The duration in seconds of a run." }, "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." } }, "required": [ "id", "started_at", "stopped_at", "status", "duration", "credits_used" ] }, "description": "Recent job 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 job 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.", "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": "path", "name": "job-name", "description": "The name of the job.", "schema": { "type": "string" }, "required": true, "example": "lint" }, { "in": "query", "name": "branch", "description": "The name of a vcs branch. If not passed we will scope the API call to the default branch. \n Note - Querying all branches is not supported yet.", "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/jobs/lint',\n qs: {\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/jobs/lint?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/jobs/lint?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/jobs/lint?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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/jobs/lint?branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&start-date=SOME_STRING_VALUE&end-date=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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." }, "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" }, "window_start": { "type": "string", "format": "date-time", "description": "The start of the aggregation window for workflow metrics." }, "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 end of the aggregation window for workflow metrics." }, "throughput": { "type": "number", "format": "float", "description": "The average number of runs per day." } }, "required": [ "window_start", "total_runs", "throughput", "total_credits_used", "window_end", "successful_runs", "success_rate", "duration_metrics", "mttr", "failed_runs" ], "description": "Metrics aggregated acrooss 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 acrooss 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.", "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": "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" } ], "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', branches: '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/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branches=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/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branches=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/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branches=SOME_OBJECT_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/insights/gh/CircleCI-Public/api-preview-docs/workflows/build-and-test/summary?all-branches=SOME_BOOLEAN_VALUE&branches=SOME_OBJECT_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/me\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/me/collaborations\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/pipeline": { "get": { "summary": "get", "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." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": [ "config", "config-fetch", "timeout", "permission", "other", "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." }, "trigger_parameters": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "integer", "format": "int64" }, { "type": "string" }, { "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//head` for the PR ref or `pull//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": [ "created_at", "errors", "id", "number", "project_slug", "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`", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/pipeline?org-slug=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE&mine=SOME_BOOLEAN_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/pipeline/continue": { "post": { "summary": "Continue a pipeline (Preview)", "description": "Continue a pipeline from the setup phase.", "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.", "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}}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/pipeline/continue\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"continuation-key\\\":\\\"string\\\",\\\"configuration\\\":\\\"string\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/pipeline/{pipeline-id}": { "get": { "summary": "Get a pipeline", "description": "Returns a pipeline by 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." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": [ "config", "config-fetch", "timeout", "permission", "other", "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." }, "trigger_parameters": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "integer", "format": "int64" }, { "type": "string" }, { "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//head` for the PR ref or `pull//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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline/%7Bpipeline-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/pipeline/%7Bpipeline-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/pipeline/%7Bpipeline-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/pipeline/%7Bpipeline-id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/pipeline/%7Bpipeline-id%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/pipeline/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/config \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/pipeline/%7Bpipeline-id%7D/config\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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." }, "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." }, "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 }, { "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/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/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/%7Bpipeline-id%7D/workflow?page-token=SOME_STRING_VALUE' \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/pipeline/%7Bpipeline-id%7D/workflow?page-token=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/project/{project-slug}/checkout-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" ], "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.", "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/checkout-key',\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\", 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\"\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 \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "post": { "summary": "Create a new checkout key", "description": "Creates a new checkout key. This API request is only usable with a user API token.", "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" ], "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.", "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\"}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/checkout-key\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"type\\\":\\\"deploy-key\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/project/{project-slug}/checkout-key/{fingerprint}": { "get": { "summary": "Get a checkout key", "description": "Returns an individual checkout key.", "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" ], "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "delete": { "summary": "Delete a checkout key", "description": "Deletes the checkout key.", "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"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\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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" } }, "required": [ "name", "value" ], "title": "EnvironmentVariablePair" } } } }, "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.", "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" ], "title": "EnvironmentVariablePair" } } } }, "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\"}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"name\\\":\\\"foo\\\",\\\"value\\\":\\\"xxxx1234\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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" } }, "required": [ "name", "value" ], "title": "EnvironmentVariablePair" } }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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" } }, "required": [ "name", "value" ], "title": "EnvironmentVariablePair" } } } }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/envvar/foo\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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": { "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." } }, "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/project/{project-slug}/job/{job-number}/cancel": { "post": { "summary": "Cancel job", "description": "Cancel job with a given job number.", "tags": [ "Job" ], "operationId": "cancelJob", "responses": { "202": { "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/job/123/cancel\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/project/{project-slug}/pipeline": { "post": { "summary": "Trigger a new pipeline", "description": "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." }, "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." }, "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.", "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//head` for the PR ref or `pull//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.", "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}}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"branch\\\":\\\"feature/design-new-api\\\",\\\"tag\\\":\\\"v3.1.4159\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true}}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": [ "config", "config-fetch", "timeout", "permission", "other", "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." }, "trigger_parameters": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "integer", "format": "int64" }, { "type": "string" }, { "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//head` for the PR ref or `pull//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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline?branch=SOME_STRING_VALUE&page-token=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": [ "config", "config-fetch", "timeout", "permission", "other", "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." }, "trigger_parameters": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "integer", "format": "int64" }, { "type": "string" }, { "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//head` for the PR ref or `pull//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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/mine?page-token=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/project/{project-slug}/pipeline/{pipeline-number}": { "get": { "summary": "Get a pipeline", "description": "Returns a pipeline by 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." }, "errors": { "type": "array", "items": { "type": "object", "properties": { "type": { "enum": [ "config", "config-fetch", "timeout", "permission", "other", "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." }, "trigger_parameters": { "type": "object", "additionalProperties": { "anyOf": [ { "type": "integer", "format": "int64" }, { "type": "string" }, { "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//head` for the PR ref or `pull//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.", "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 } ], "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/%7Bpipeline-number%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/project/gh/CircleCI-Public/api-preview-docs/pipeline/%7Bpipeline-number%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/project/gh/CircleCI-Public/api-preview-docs/pipeline/%7Bpipeline-number%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/project/gh/CircleCI-Public/api-preview-docs/pipeline/%7Bpipeline-number%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/pipeline/%7Bpipeline-number%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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": { "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." } }, "required": [ "per-hour", "hours-of-day", "days-of-week" ], "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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule?page-token=SOME_STRING_VALUE\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "post": { "summary": "Create a schedule", "description": "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": { "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." } }, "required": [ "per-hour", "hours-of-day", "days-of-week" ], "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.", "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": { "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." } }, "required": [ "per-hour", "hours-of-day", "days-of-week" ], "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: {'per-hour': 0, 'hours-of-day': [0], 'days-of-week': ['TUE']},\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\\\"]},\\\"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\\\"]},\\\"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\"]},\"attribution-actor\":\"current\",\"parameters\":{\"deploy_prod\":true,\"branch\":\"feature/design-new-api\"},\"description\":\"string\"}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/schedule\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"},\\\"description\\\":\\\"string\\\"}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/artifacts\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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.", "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/project/gh/CircleCI-Public/api-preview-docs/123/tests\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/schedule/{schedule-id}": { "delete": { "summary": "Delete a schedule", "description": "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Delete.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "patch": { "summary": "Update a schedule", "description": "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": { "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." } }, "required": [ "per-hour", "hours-of-day", "days-of-week" ], "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." } }, "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: {'per-hour': 0, 'hours-of-day': [0], 'days-of-week': ['TUE']},\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\\\"]},\\\"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\\\"]},\\\"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\"]},\"attribution-actor\":\"current\",\"parameters\":{\"deploy_prod\":true,\"branch\":\"feature/design-new-api\"}}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Patch.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"description\\\":\\\"string\\\",\\\"name\\\":\\\"string\\\",\\\"timetable\\\":{\\\"per-hour\\\":0,\\\"hours-of-day\\\":[0],\\\"days-of-week\\\":[\\\"TUE\\\"]},\\\"attribution-actor\\\":\\\"current\\\",\\\"parameters\\\":{\\\"deploy_prod\\\":true,\\\"branch\\\":\\\"feature/design-new-api\\\"}}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] }, "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": { "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." } }, "required": [ "per-hour", "hours-of-day", "days-of-week" ], "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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/schedule/%7Bschedule-id%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/user/%7Bid%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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." }, "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." }, "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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/workflow/%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/workflow/%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/workflow/%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/workflow/%7Bid%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/workflow/%7Bid%7D\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/workflow/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/approve/%7Bapproval_request_id%7D \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/workflow/%7Bid%7D/approve/%7Bapproval_request_id%7D\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'POST',\n url: 'https://circleci.com/api/v2/workflow/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/cancel \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/workflow/%7Bid%7D/cancel\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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": { "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 } ], "x-codeSamples": [ { "lang": "Node + Request", "source": "const request = require('request');\n\nconst options = {\n method: 'GET',\n url: 'https://circleci.com/api/v2/workflow/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/job \\\n --header 'authorization: Basic REPLACE_BASIC_AUTH'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/workflow/%7Bid%7D/job\")\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[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\n\nresponse = http.request(request)\nputs response.read_body" } ] } }, "/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 } ], "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/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/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/%7Bid%7D/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}'" }, { "lang": "Ruby + Native", "source": "require 'uri'\nrequire 'net/http'\nrequire 'openssl'\n\nurl = URI(\"https://circleci.com/api/v2/workflow/%7Bid%7D/rerun\")\n\nhttp = Net::HTTP.new(url.host, url.port)\nhttp.use_ssl = true\nhttp.verify_mode = OpenSSL::SSL::VERIFY_NONE\n\nrequest = Net::HTTP::Post.new(url)\nrequest[\"content-type\"] = 'application/json'\nrequest[\"authorization\"] = 'Basic REPLACE_BASIC_AUTH'\nrequest.body = \"{\\\"enable_ssh\\\":false,\\\"from_failed\\\":false,\\\"jobs\\\":[\\\"c65b68ef-e73b-4bf2-be9a-7a322a9df150\\\",\\\"5e957edd-5e8c-4985-9178-5d0d69561822\\\"],\\\"sparse_tree\\\":false}\"\n\nresponse = http.request(request)\nputs response.read_body" } ] } } }, "components": { "securitySchemes": { "api_key_header": { "type": "apiKey", "name": "Circle-Token", "in": "header" }, "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" } } }, "tags": [ { "name": "Context" }, { "name": "Insights" }, { "name": "User", "x-displayName": "User (Preview)" }, { "name": "Pipeline" }, { "name": "Job", "x-displayName": "Job (Preview)" }, { "name": "Workflow" } ] }