Skip to main content
Ahora la API REST está versionada. Para obtener más información, consulta "Acerca del control de versiones de la API".

Centros de costo

Use la API REST para obtener información del centro de costos.

Roles necesarios

Los roles siguientes pueden acceder a los puntos de conexión de la API del centro de costos:

  •         **Propietarios de empresas**
    
  •         **Administradores de facturación**
    
  •         **Propietarios de la organización**
    

Get all cost centers for an enterprise

Gets a list of all the cost centers for an enterprise.

Tokens de acceso granulares para "Get all cost centers for an enterprise"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Get all cost centers for an enterprise"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

Parámetros de consulta
Nombre, Tipo, Descripción
state string

Set to active or deleted to only list cost centers in a specific state.

Puede ser uno de los siguientes: active, deleted

Códigos de estado de respuesta HTTP para "Get all cost centers for an enterprise"

código de estadoDescripción
200

Response when getting cost centers

400

Bad Request

403

Forbidden

500

Internal Error

503

Service unavailable

Ejemplos de código para "Get all cost centers for an enterprise"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/enterprises/{enterprise}/settings/billing/cost-centers
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

Response 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": "Repo", "name": "octocat/hello-world" } ] }, { "id": "3ffb9ffe-6903-11ee-8c99-0242ac120003", "name": "Another Cost Center", "state": "active", "resources": [ { "type": "User", "name": "Octocat" } ] } ] }

Create a new cost center

Creates a new cost center for an enterprise. The authenticated user must be an enterprise admin.

Tokens de acceso granulares para "Create a new cost center"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Create a new cost center"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

Parámetros del cuerpo
Nombre, Tipo, Descripción
name string Obligatorio

The name of the cost center (max length 255 characters)

Códigos de estado de respuesta HTTP para "Create a new cost center"

código de estadoDescripción
200

Cost center created successfully

400

Bad request

409

Conflict

500

Internal server error

Ejemplos de código para "Create a new cost center"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

post/enterprises/{enterprise}/settings/billing/cost-centers
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": [] }

Get a cost center by ID

Gets a cost center by ID. The authenticated user must be an enterprise admin.

Tokens de acceso granulares para "Get a cost center by ID"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Get a cost center by ID"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

cost_center_id string Obligatorio

The ID corresponding to the cost center.

Parámetros de consulta
Nombre, Tipo, Descripción
page integer

The page number of the results to fetch. For more information, see "Using pagination in the REST API."

Valor predeterminado: 1

per_page integer

The number of results per page (max 100). For more information, see "Using pagination in the REST API."

Valor predeterminado: 30

Códigos de estado de respuesta HTTP para "Get a cost center by ID"

código de estadoDescripción
200

Response when getting a cost center

400

Bad Request

403

Forbidden

500

Internal Error

503

Service unavailable

Ejemplos de código para "Get a cost center by ID"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

get/enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}
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_ID

Response 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": "Repo", "name": "octocat/hello-world" } ] }

Update a cost center name

Updates an existing cost center name.

Tokens de acceso granulares para "Update a cost center name"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Update a cost center name"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name

cost_center_id string Obligatorio

The unique identifier of the cost center

Parámetros del cuerpo
Nombre, Tipo, Descripción
name string Obligatorio

The new name for the cost center

Códigos de estado de respuesta HTTP para "Update a cost center name"

código de estadoDescripción
200

Response when updating a cost center

400

Bad Request

403

Forbidden

404

Resource not found

409

Conflict

500

Internal Error

503

Service unavailable

Ejemplos de código para "Update a cost center name"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

patch/enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}
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": "Repo", "name": "octocat/hello-world" } ] }

Delete a cost center

Archieves a cost center by ID. The authenticated user must be an enterprise admin.

Tokens de acceso granulares para "Delete a cost center"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Delete a cost center"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

cost_center_id string Obligatorio

The ID corresponding to the cost center.

Códigos de estado de respuesta HTTP para "Delete a cost center"

código de estadoDescripción
200

Response when deleting a cost center

400

Bad Request

403

Forbidden

404

Resource not found

500

Internal Error

503

Service unavailable

Ejemplos de código para "Delete a cost center"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}
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

Response 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. The authenticated user must be an enterprise admin in order to use this endpoint.

Tokens de acceso granulares para "Add resources to a cost center"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Add resources to a cost center"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

cost_center_id string Obligatorio

The ID corresponding to the cost center.

Parámetros del cuerpo
Nombre, Tipo, Descripción
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.

Códigos de estado de respuesta HTTP para "Add resources to a cost center"

código de estadoDescripción
200

Response when adding resources to a cost center

400

Bad Request

403

Forbidden

409

Conflict

500

Internal Error

503

Service unavailable

Ejemplos de código para "Add resources to a cost center"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

post/enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource
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" } ] }

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. The authenticated user must be an enterprise admin in order to use this endpoint.

Tokens de acceso granulares para "Remove resources from a cost center"

Este punto de acceso no funciona con tokens de acceso de usuario de la aplicación de GitHub, tokens de acceso de instalación de la aplicación de GitHub ni tokens de acceso personales de granulación fina.

Parámetros para "Remove resources from a cost center"

Encabezados
Nombre, Tipo, Descripción
accept string

Setting to application/vnd.github+json is recommended.

Parámetros de ruta
Nombre, Tipo, Descripción
enterprise string Obligatorio

The slug version of the enterprise name.

cost_center_id string Obligatorio

The ID corresponding to the cost center.

Parámetros del cuerpo
Nombre, Tipo, Descripción
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.

Códigos de estado de respuesta HTTP para "Remove resources from a cost center"

código de estadoDescripción
200

Response when removing resources from a cost center

400

Bad Request

403

Forbidden

500

Internal Error

503

Service unavailable

Ejemplos de código para "Remove resources from a cost center"

Si accedes a GitHub en GHE.com, reemplaza api.github.com por el subdominio dedicado de la empresa en api.SUBDOMAIN.ghe.com.

Ejemplo de solicitud

delete/enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource
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." }