Centros de custo
Use a API REST para obter informações do centro de custo.
Funções necessárias
As seguintes funções podem acessar endpoints da API do centro de custos:
- Proprietários corporativos
- Gerentes de cobrança
- Proprietários da organização
Get all cost centers for an enterprise
Gets a list of all the cost centers for an enterprise. Enterprise owners and billing managers can view all cost centers, and organization owners can view cost centers associated with resources they administer. A custom role holder with fine-grained read access to enterprise billing can also view cost centers. An installation access token for a GitHub App installed on the enterprise with read access to enterprise billing can list all cost centers in the enterprise.
Tokens de acesso granulares para "Get all cost centers for an enterprise"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (read)
Parâmetros para "Get all cost centers for an enterprise"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
| Nome, Tipo, Descrição |
|---|
state string Set to Pode ser um dos: |
Códigos de status de resposta HTTP para "Get all cost centers for an enterprise"
| Código de status | Descrição |
|---|---|
200 | Response when getting cost centers |
400 | Bad Request |
403 | Forbidden |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Get all cost centers for an enterprise"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centersResponse when getting cost centers
Status: 200{
"costCenters": [
{
"id": "2eeb8ffe-6903-11ee-8c99-0242ac120002",
"name": "Cost Center Name",
"state": "active",
"azure_subscription": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"resources": [
{
"type": "User",
"name": "Monalisa"
},
{
"type": "Team",
"name": "enterprise-team-1"
}
],
"ai_credit_pool_enabled": true,
"ai_credit_pool_state": {
"target_amount": 21000,
"current_amount": 7250.5
}
},
{
"id": "3ffb9ffe-6903-11ee-8c99-0242ac120003",
"name": "Another Cost Center",
"state": "active",
"resources": [
{
"type": "User",
"name": "Octocat"
},
{
"type": "Team",
"name": "enterprise-team-2"
},
{
"type": "Repo",
"name": "octocat/hello-world"
}
],
"ai_credit_pool_enabled": false
}
]
}Create a new cost center
Creates a new cost center for an enterprise. Enterprise owners and billing managers can create cost centers. A custom role holder with fine-grained write access to enterprise billing can also create cost centers. An installation access token for a GitHub App installed on the enterprise with write access to enterprise billing can create cost centers in the enterprise.
Tokens de acesso granulares para "Create a new cost center"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (write)
Parâmetros para "Create a new cost center"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
| Nome, Tipo, Descrição |
|---|
name string ObrigatórioThe name of the cost center (max length 255 characters) |
ai_credit_pool_enabled boolean Whether the cost center draws from the AI credit pool. This can only be enabled for cost centers that contain only user or team resources.
|
Códigos de status de resposta HTTP para "Create a new cost center"
| Código de status | Descrição |
|---|---|
200 | Cost center created successfully |
400 | Bad request |
409 | Conflict |
500 | Internal server error |
Exemplos de código para "Create a new cost center"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers \
-d '{"name":"Engineering Team"}'Example response for a created cost center
Status: 200{
"id": "abc123",
"name": "Engineering Team",
"resources": [],
"ai_credit_pool_enabled": true,
"ai_credit_pool_state": {
"target_amount": null,
"current_amount": null
}
}Get a cost center by ID
Gets a cost center by ID. Enterprise owners and billing managers can view any cost center, and organization owners can view cost centers associated with resources they administer. A custom role holder with fine-grained read access to enterprise billing can also view the cost center. An installation access token for a GitHub App installed on the enterprise with read access to enterprise billing can get any cost center in the enterprise.
Tokens de acesso granulares para "Get a cost center by ID"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (read)
Parâmetros para "Get a cost center by ID"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
cost_center_id string ObrigatórioThe ID corresponding to the cost center. |
| Nome, Tipo, Descrição |
|---|
page integer The page number of the results to fetch. For more information, see "Using pagination in the REST API." Padrão: |
per_page integer The number of results per page (max 100). For more information, see "Using pagination in the REST API." Padrão: |
Códigos de status de resposta HTTP para "Get a cost center by ID"
| Código de status | Descrição |
|---|---|
200 | Response when getting a cost center |
400 | Bad Request |
403 | Forbidden |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Get a cost center by ID"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_IDResponse when getting a cost center
Status: 200{
"id": "2eeb8ffe-6903-11ee-8c99-0242ac120002",
"name": "Cost Center Name",
"state": "active",
"azure_subscription": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"resources": [
{
"type": "User",
"name": "Monalisa"
},
{
"type": "Team",
"name": "enterprise-team-1"
}
],
"ai_credit_pool_enabled": true,
"ai_credit_pool_state": {
"target_amount": 21000,
"current_amount": 7250.5
}
}Update a cost center
Updates an existing cost center. Enterprise owners and billing managers can update any cost center, and organization owners can update cost centers associated with resources they administer. A custom role holder with fine-grained write access to enterprise billing can also update cost centers. An installation access token for a GitHub App installed on the enterprise with write access to enterprise billing can update any cost center in the enterprise.
Tokens de acesso granulares para "Update a cost center"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (write)
Parâmetros para "Update a cost center"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name |
cost_center_id string ObrigatórioThe unique identifier of the cost center |
| Nome, Tipo, Descrição |
|---|
name string The new name for the cost center |
ai_credit_pool_enabled boolean Whether the cost center draws from the AI credit pool. This can only be enabled for cost centers that contain only user or team resources.
|
Códigos de status de resposta HTTP para "Update a cost center"
| Código de status | Descrição |
|---|---|
200 | Response when updating a cost center |
400 | Bad Request |
403 | Forbidden |
404 | Resource not found |
409 | Conflict |
422 | Validation failed, or the endpoint has been spammed. |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Update a cost center"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplos de solicitação
curl -L \
-X PATCH \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID \
-d '{"name":"New Cost Center Name"}'Response when updating a cost center
Status: 200{
"id": "2eeb8ffe-6903-11ee-8c99-0242ac120002",
"name": "Cost Center Name",
"state": "active",
"azure_subscription": "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee",
"resources": [
{
"type": "User",
"name": "Monalisa"
},
{
"type": "Team",
"name": "enterprise-team-1"
}
],
"ai_credit_pool_enabled": true,
"ai_credit_pool_state": {
"target_amount": 21000,
"current_amount": 7250.5
}
}Delete a cost center
Archives a cost center by ID. Enterprise owners and billing managers can archive any cost center, and organization owners can archive cost centers associated with resources they administer. A custom role holder with fine-grained write access to enterprise billing can also archive cost centers. An installation access token for a GitHub App installed on the enterprise with write access to enterprise billing can archive any cost center in the enterprise.
Tokens de acesso granulares para "Delete a cost center"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (write)
Parâmetros para "Delete a cost center"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
cost_center_id string ObrigatórioThe ID corresponding to the cost center. |
Códigos de status de resposta HTTP para "Delete a cost center"
| Código de status | Descrição |
|---|---|
200 | Response when deleting a cost center |
400 | Bad Request |
403 | Forbidden |
404 | Resource not found |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Delete a cost center"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_IDResponse when deleting a cost center
Status: 200{
"message": "Cost center successfully deleted.",
"id": "2066deda-923f-43f9-88d2-62395a28c0cdd",
"name": "cc3",
"costCenterState": "CostCenterArchived"
}Add resources to a cost center
Adds resources to a cost center.
The usage for the resources will be charged to the cost center's budget. Enterprise owners and billing managers can add any resource, and organization owners can add non-team resources to cost centers associated with resources they administer. A custom role holder with fine-grained write access to enterprise billing can add users in the enterprise who are visible to them and organizations or repositories they administer, but cannot add enterprise teams. An installation access token for a GitHub App installed on the enterprise with write access to enterprise billing can add resources to any cost center in the enterprise.
Tokens de acesso granulares para "Add resources to a cost center"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (write)
Parâmetros para "Add resources to a cost center"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
cost_center_id string ObrigatórioThe ID corresponding to the cost center. |
| Nome, Tipo, Descrição |
|---|
users array of strings The usernames of the users to add to the cost center. |
organizations array of strings The organizations to add to the cost center. |
repositories array of strings The repositories to add to the cost center. |
enterprise_teams array of strings The enterprise teams to add to the cost center. |
Códigos de status de resposta HTTP para "Add resources to a cost center"
| Código de status | Descrição |
|---|---|
200 | Response when adding resources to a cost center |
400 | Bad Request |
403 | Forbidden |
409 | Conflict |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Add resources to a cost center"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-X POST \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID/resource \
-d '{"users":["monalisa"]}'Response when adding resources to a cost center
Status: 200{
"message": "Resources successfully added to the cost center.",
"reassigned_resources": [
{
"resource_type": "user",
"name": "monalisa",
"previous_cost_center": "old-cost-center"
},
{
"resource_type": "organization",
"name": "octo-org",
"previous_cost_center": "another-cost-center"
},
{
"resource_type": "repository",
"name": "octo-repo",
"previous_cost_center": "yet-another-cost-center"
},
{
"resource_type": "team",
"name": "octo-enterprise-team",
"previous_cost_center": "old-cost-center"
}
]
}Remove resources from a cost center
Remove resources from a cost center.
The usage for the resources will no longer be charged to the cost center's budget. Enterprise owners and billing managers can remove any resource, and organization owners can remove non-team resources from cost centers associated with resources they administer. A custom role holder with fine-grained write access to enterprise billing can remove users and any organizations or repositories they administer; only enterprise owners and billing managers can remove enterprise teams. An installation access token for a GitHub App installed on the enterprise with write access to enterprise billing can remove users from any cost center in the enterprise.
Tokens de acesso granulares para "Remove resources from a cost center"
Este endpoint funciona com os seguintes tipos de token granulares:
O token refinado deve ter os seguintes conjuntos de permissões:
- "Enterprise billing" enterprise permissions (write)
Parâmetros para "Remove resources from a cost center"
| Nome, Tipo, Descrição |
|---|
accept string Setting to |
| Nome, Tipo, Descrição |
|---|
enterprise string ObrigatórioThe slug version of the enterprise name. |
cost_center_id string ObrigatórioThe ID corresponding to the cost center. |
| Nome, Tipo, Descrição |
|---|
users array of strings The usernames of the users to remove from the cost center. |
organizations array of strings The organizations to remove from the cost center. |
repositories array of strings The repositories to remove from the cost center. |
enterprise_teams array of strings The enterprise teams to remove from the cost center. |
Códigos de status de resposta HTTP para "Remove resources from a cost center"
| Código de status | Descrição |
|---|---|
200 | Response when removing resources from a cost center |
400 | Bad Request |
403 | Forbidden |
500 | Internal Error |
503 | Service unavailable |
Exemplos de código para "Remove resources from a cost center"
Se você acessar GitHub em GHE.com, substitua api.github.com pelo subdomínio dedicado da sua empresa em api.SUBDOMAIN.ghe.com.
Exemplo de solicitação
curl -L \
-X DELETE \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
-H "X-GitHub-Api-Version: 2026-03-10" \
https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID/resource \
-d '{"users":["monalisa"]}'Response when removing resources from a cost center
Status: 200{
"message": "Resources successfully removed from the cost center."
}