---
title: Update Custom Costs file
description: Mark whether a Custom Costs file holds AI provider costs. Datadog then recomputes the costs for the months that the file covers.
breadcrumbs: Docs > API > Update Custom Costs file
---

> For the complete documentation index, see [llms.txt](https://docs.datadoghq.com/llms.txt).

# Update Custom Costs file

## v2 (latest)

| Datadog site      | API endpoint                                                           |
| ----------------- | ---------------------------------------------------------------------- |
| app.datadoghq.com | PATCH https://api.datadoghq.com/api/v2/cost/custom_costs/{file_id}     |
| us3.datadoghq.com | PATCH https://api.us3.datadoghq.com/api/v2/cost/custom_costs/{file_id} |
| us5.datadoghq.com | PATCH https://api.us5.datadoghq.com/api/v2/cost/custom_costs/{file_id} |
| app.datadoghq.eu  | PATCH https://api.datadoghq.eu/api/v2/cost/custom_costs/{file_id}      |
| ap1.datadoghq.com | PATCH https://api.ap1.datadoghq.com/api/v2/cost/custom_costs/{file_id} |
| ap2.datadoghq.com | PATCH https://api.ap2.datadoghq.com/api/v2/cost/custom_costs/{file_id} |
| uk1.datadoghq.com | PATCH https://api.uk1.datadoghq.com/api/v2/cost/custom_costs/{file_id} |
| app.ddog-gov.com  | PATCH https://api.ddog-gov.com/api/v2/cost/custom_costs/{file_id}      |
| us2.ddog-gov.com  | PATCH https://api.us2.ddog-gov.com/api/v2/cost/custom_costs/{file_id}  |

### Overview

Mark whether a Custom Costs file holds AI provider costs. Datadog then recomputes the costs for the months that the file covers.

This endpoint requires the `cloud_cost_management_write` permission.

OAuth apps require the `cloud_cost_management_write` authorization [scope](https://docs.datadoghq.com/api/latest/scopes.md#cloud-cost-management) to access this endpoint.

### Arguments

#### Path Parameters

| Field                | Type   | Description |
| -------------------- | ------ | ----------- |
| file_id [*required*] | string | File ID.    |

### Request

#### Body Data (required)

{% tabs %}
{% tab label="Model" %}
| Parent field | Field                    | Type    | Description                                                                                             |
| ------------ | ------------------------ | ------- | ------------------------------------------------------------------------------------------------------- |
|              | data [*required*]        | object  | Custom Costs file to update.                                                                            |
| data         | attributes [*required*]  | object  | Attributes of a Custom Costs file that can be updated.                                                  |
| attributes   | ai_provider [*required*] | boolean | Whether the Custom Costs file contains the costs of an AI provider.                                     |
| data         | id [*required*]          | string  | ID of the Custom Costs file.                                                                            |
| data         | type [*required*]        | enum    | Type of the Custom Costs file resource. Allowed enum values: `cost_metadata`. Default: `cost_metadata`. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "ai_provider": true
    },
    "id": "string",
    "type": "cost_metadata"
  }
}
```
{% /tab %}
{% /tabs %}

### Response

{% tabs %}
{% tab label="200" %}
OK

{% tabs %}
{% tab label="Model" %}
Response for Uploaded Custom Costs files.

| Parent field  | Field            | Type     | Description                                                             |
| ------------- | ---------------- | -------- | ----------------------------------------------------------------------- |
|               | data             | object   | JSON API format for a Custom Costs file.                                |
| data          | attributes       | object   | Schema of a Custom Costs metadata.                                      |
| attributes    | ai_provider      | boolean  | Whether the Custom Costs file contains the costs of an AI provider.     |
| attributes    | billed_cost      | double   | Total cost in the cost file.                                            |
| attributes    | billing_currency | string   | Currency used in the Custom Costs file.                                 |
| attributes    | charge_period    | object   | Usage charge period of a Custom Costs file.                             |
| charge_period | end              | double   | End of the usage of the Custom Costs file.                              |
| charge_period | start            | double   | Start of the usage of the Custom Costs file.                            |
| attributes    | name             | string   | Name of the Custom Costs file.                                          |
| attributes    | provider_names   | [string] | Providers contained in the Custom Costs file.                           |
| attributes    | status           | string   | Status of the Custom Costs file.                                        |
| attributes    | uploaded_at      | double   | Timestamp, in millisecond, of the upload time of the Custom Costs file. |
| attributes    | uploaded_by      | object   | Metadata of the user that has uploaded the Custom Costs file.           |
| uploaded_by   | email            | string   | The name of the Custom Costs file.                                      |
| uploaded_by   | icon             | string   | The name of the Custom Costs file.                                      |
| uploaded_by   | name             | string   | Name of the user.                                                       |
| data          | id               | string   | ID of the Custom Costs metadata.                                        |
| data          | type             | string   | Type of the Custom Costs file metadata.                                 |
|               | meta             | object   | Meta for the response from the Upload Custom Costs endpoints.           |
| meta          | version          | string   | Version of Custom Costs file                                            |
{% /tab %}

{% tab label="Example" %}
```json
{
  "data": {
    "attributes": {
      "ai_provider": false,
      "billed_cost": 100.5,
      "billing_currency": "USD",
      "charge_period": {
        "end": 1706745600000,
        "start": 1704067200000
      },
      "name": "my_file.json",
      "provider_names": [
        "my_provider"
      ],
      "status": "active",
      "uploaded_at": 1704067200000,
      "uploaded_by": {
        "email": "email.test@datadohq.com",
        "icon": "icon.png",
        "name": "Test User"
      }
    },
    "id": "string",
    "type": "string"
  },
  "meta": {
    "version": "string"
  }
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="404" %}
Not Found

{% tabs %}
{% tab label="Model" %}
API error response.

| Parent field | Field               | Type     | Description                                                                     |
| ------------ | ------------------- | -------- | ------------------------------------------------------------------------------- |
|              | errors [*required*] | [object] | A list of errors.                                                               |
| errors       | code                | string   | An application-specific error code.                                             |
| errors       | detail              | string   | A human-readable explanation specific to this occurrence of the error.          |
| errors       | meta                | object   | Non-standard meta-information about the error                                   |
| errors       | source              | object   | References to the source of the error.                                          |
| source       | header              | string   | A string indicating the name of a single request header which caused the error. |
| source       | parameter           | string   | A string indicating which URI query parameter caused the error.                 |
| source       | pointer             | string   | A JSON pointer to the value in the request document that caused the error.      |
| errors       | status              | string   | Status code of the response.                                                    |
| errors       | title               | string   | Short human-readable summary of the error.                                      |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    {
      "code": "invalid_request",
      "detail": "Missing required attribute in body",
      "meta": {},
      "source": {
        "header": "Authorization",
        "parameter": "limit",
        "pointer": "/data/attributes/title"
      },
      "status": "400",
      "title": "Bad Request"
    }
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}

{% tab label="429" %}
Too many requests

{% tabs %}
{% tab label="Model" %}
API error response.

| Field               | Type     | Description       |
| ------------------- | -------- | ----------------- |
| errors [*required*] | [string] | A list of errors. |
{% /tab %}

{% tab label="Example" %}
```json
{
  "errors": [
    "Bad Request"
  ]
}
```
{% /tab %}
{% /tabs %}
{% /tab %}
{% /tabs %}

### Code Example

{% tabs %}
{% tab label="Curl" %}
```bash
# Path parameters
export file_id="CHANGE_ME"

# Set your Datadog site and credentials
export DD_SITE="datadoghq.com" # Or us3.datadoghq.com, us5.datadoghq.com, datadoghq.eu, ap1.datadoghq.com, ap2.datadoghq.com, uk1.datadoghq.com, ddog-gov.com, us2.ddog-gov.com
# Use a Personal Access Token or Service Access Token
export DD_BEARER_TOKEN="<PERSONAL_ACCESS_TOKEN OR SERVICE_ACCESS_TOKEN>"

curl -X PATCH "https://api.${DD_SITE}/api/v2/cost/custom_costs/${file_id}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${DD_BEARER_TOKEN}" \
-d @- << EOF
{
  "data": {
    "attributes": {
      "ai_provider": true
    },
    "id": "string",
    "type": "cost_metadata"
  }
}
EOF
```
{% /tab %}
{% /tabs %}
