# Cost centers

Use the REST API to get cost center information.

## Required roles

The following roles can access cost center API endpoints:

* **Enterprise owners**
* **Billing managers**
* **Organization owners**

> [!NOTE]
> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.

## Get all cost centers for an enterprise

```
GET /enterprises/{enterprise}/settings/billing/cost-centers
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

- **`state`** (string)
  Set to active or deleted to only list cost centers in a specific state.
  Can be one of: `active`, `deleted`

### HTTP response status codes

- **200** - Response when getting cost centers

- **400** - Bad Request

- **403** - Forbidden

- **500** - Internal Error

- **503** - Service unavailable

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers
```

**Response schema (Status: 200):**

* `costCenters`: array of objects:
  * `id`: required, string
  * `name`: required, string
  * `state`: string, enum: `active`, `deleted`
  * `azure_subscription`: string or null
  * `ai_credit_pool_enabled`: boolean
  * `ai_credit_pool_state`: object:
    * `target_amount`: number or null
    * `current_amount`: number or null
  * `resources`: required, array of objects:
    * `type`: required, string
    * `name`: required, string

## Create a new cost center

```
POST /enterprises/{enterprise}/settings/billing/cost-centers
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

#### Body parameters

- **`name`** (string) (required)
  The 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.

false — no cap; the cost center draws from the shared enterprise pool.
true — the cost center is capped at an amount derived from its members' license entitlements.

### HTTP response status codes

- **200** - Cost center created successfully

- **400** - Bad request

- **409** - Conflict

- **500** - Internal server error

### Code examples

#### Example request to create a cost center

**Request:**

```curl
curl -L \
  -X POST \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers \
  -d '{
  "name": "Engineering Team"
}'
```

**Response schema (Status: 200):**

* `id`: string
* `name`: string
* `azure_subscription`: string or null
* `state`: string, enum: `active`, `deleted`
* `resources`: array of objects:
  * `type`: string
  * `name`: string
* `ai_credit_pool_enabled`: boolean
* `ai_credit_pool_state`: object:
  * `target_amount`: number or null
  * `current_amount`: number or null

## Get a cost center by ID

```
GET /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

- **`cost_center_id`** (string) (required)
  The ID corresponding to the cost center.

- **`page`** (integer)
  The page number of the results to fetch. For more information, see "Using pagination in the REST API."
  Default: `1`

- **`per_page`** (integer)
  The number of results per page (max 100). For more information, see "Using pagination in the REST API."
  Default: `30`

### HTTP response status codes

- **200** - Response when getting a cost center

- **400** - Bad Request

- **403** - Forbidden

- **500** - Internal Error

- **503** - Service unavailable

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X GET \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID
```

**Response schema (Status: 200):**

* `id`: required, string
* `name`: required, string
* `azure_subscription`: string or null
* `state`: string, enum: `active`, `deleted`
* `resources`: required, array of objects:
  * `type`: required, string
  * `name`: required, string
* `has_next_page`: boolean
* `ai_credit_pool_enabled`: boolean
* `ai_credit_pool_state`: object:
  * `target_amount`: number or null
  * `current_amount`: number or null

## Update a cost center

```
PATCH /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name

- **`cost_center_id`** (string) (required)
  The unique identifier of the cost center

#### Body parameters

- **`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.

false — no cap; the cost center draws from the shared enterprise pool.
true — the cost center is capped at an amount derived from its members' license entitlements.

### HTTP response status codes

- **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

### Code examples

#### Update cost center name example

**Request:**

```curl
curl -L \
  -X PATCH \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID \
  -d '{
  "name": "New Cost Center Name"
}'
```

**Response schema (Status: 200):**

* `id`: required, string
* `name`: required, string
* `azure_subscription`: string or null
* `state`: string, enum: `active`, `deleted`
* `resources`: required, array of objects:
  * `type`: required, string
  * `name`: required, string
* `ai_credit_pool_enabled`: boolean
* `ai_credit_pool_state`: object:
  * `target_amount`: number or null
  * `current_amount`: number or null

#### Update cost center with AI credit pool enabled

**Request:**

```curl
curl -L \
  -X PATCH \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID \
  -d '{
  "ai_credit_pool_enabled": true
}'
```

**Response schema (Status: 200):**

* `id`: required, string
* `name`: required, string
* `azure_subscription`: string or null
* `state`: string, enum: `active`, `deleted`
* `resources`: required, array of objects:
  * `type`: required, string
  * `name`: required, string
* `ai_credit_pool_enabled`: boolean
* `ai_credit_pool_state`: object:
  * `target_amount`: number or null
  * `current_amount`: number or null

## Delete a cost center

```
DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

- **`cost_center_id`** (string) (required)
  The ID corresponding to the cost center.

### HTTP response status codes

- **200** - Response when deleting a cost center

- **400** - Bad Request

- **403** - Forbidden

- **404** - Resource not found

- **500** - Internal Error

- **503** - Service unavailable

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X DELETE \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID
```

**Response schema (Status: 200):**

* `message`: required, string
* `id`: required, string
* `name`: required, string
* `costCenterState`: required, string, enum: `CostCenterArchived`

## Add resources to a cost center

```
POST /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

- **`cost_center_id`** (string) (required)
  The ID corresponding to the cost center.

#### Body parameters

- **`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.

### HTTP response status codes

- **200** - Response when adding resources to a cost center

- **400** - Bad Request

- **403** - Forbidden

- **409** - Conflict

- **500** - Internal Error

- **503** - Service unavailable

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X POST \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID/resource \
  -d '{
  "users": [
    "monalisa"
  ]
}'
```

**Response schema (Status: 200):**

* `message`: string
* `reassigned_resources`: array of objects or null:
  * `resource_type`: string
  * `name`: string
  * `previous_cost_center`: string

## Remove resources from a cost center

```
DELETE /enterprises/{enterprise}/settings/billing/cost-centers/{cost_center_id}/resource
```

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.

### Parameters

#### Headers

- **`accept`** (string)
  Setting to `application/vnd.github+json` is recommended.

#### Path and query parameters

- **`enterprise`** (string) (required)
  The slug version of the enterprise name.

- **`cost_center_id`** (string) (required)
  The ID corresponding to the cost center.

#### Body parameters

- **`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.

### HTTP response status codes

- **200** - Response when removing resources from a cost center

- **400** - Bad Request

- **403** - Forbidden

- **500** - Internal Error

- **503** - Service unavailable

### Code examples

#### Example

**Request:**

```curl
curl -L \
  -X DELETE \
  https://api.github.com/enterprises/ENTERPRISE/settings/billing/cost-centers/COST_CENTER_ID/resource \
  -d '{
  "users": [
    "monalisa"
  ]
}'
```

**Response schema (Status: 200):**

* `message`: string