---
title: "Update a user"
description: "Users are created automatically from usage. Use this endpoint to set budgets or update profile fields after creation."
---

<a id="playground-button:docs/apis/users/update-user"></a>

**PATCH** `https://api.respan.ai/api/users/{customer_identifier}/`

Users are created automatically from usage. Use this endpoint to set budgets or update profile fields after creation.

## Servers

`https://api.respan.ai`: Respan API Server

<a id="request.auth"></a>

## Authentication

<a id="request.auth.Authorization"></a>

### RespanApiKey

Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer &lt;RESPAN_API_KEY&gt;. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -&gt; Providers or respan_params.credential_override in the request body, not in this authentication field.

HTTP scheme: `bearer`; format: `Respan API key`.


```http
Authorization: Bearer $RESPAN_API_KEY
```


**Or:**

### DashboardJwt

Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.

HTTP scheme: `bearer`; format: `Dashboard JWT`.


```http
Authorization: Bearer $RESPAN_DASHBOARD_JWT
```


<a id="request.path"></a>

## Path parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.path.customer_identifier"></a>`customer_identifier` | `string` | Required | Your unique identifier for this user. |


<a id="request.query"></a>

## Query parameters


| Parameter | Type | Required | Description and constraints |
| --- | --- | --- | --- |
| <a id="request.query.environment"></a>`environment` | `string` | Optional | Optional environment filter. If omitted, the backend uses the environment implied by your auth context when applicable.<br />Allowed: `"prod"`, `"test"`<br />Example: `"prod"` |


<a id="request"></a>

## Request body

A request body is required.

### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Required body | - |
| <a id="request.body.email"></a>`email` | `string or null` | Optional | User email address.<br />Example: `"alice@example.com"` |
| <a id="request.body.name"></a>`name` | `string or null` | Optional | User display name.<br />Example: `"Alice"` |
| <a id="request.body.metadata"></a>`metadata` | `object` | Optional | Custom key-value metadata.<br />Example: `{"plan":"pro","team":"engineering"}` |
| <a id="request.body.period_budget"></a>`period_budget` | `number or null` | Optional | Spending budget per period in USD.<br />Example: `100` |
| <a id="request.body.budget_duration"></a>`budget_duration` | `string` | Optional | Budget renewal period.<br />Allowed: `"daily"`, `"weekly"`, `"monthly"`<br />Example: `"monthly"` |
| <a id="request.body.total_budget"></a>`total_budget` | `number or null` | Optional | Total lifetime spending budget in USD.<br />Example: `1000` |
| <a id="request.body.period_start"></a>`period_start` | `string` | Optional | Optional custom budget period start.<br />Format: `date-time`<br />Example: `"2025-12-01T00:00:00Z"` |
| <a id="request.body.period_end"></a>`period_end` | `string or null` | Optional | Optional custom budget period end.<br />Format: `date-time`<br />Example: `"2025-12-31T23:59:59Z"` |
| <a id="request.body.markup_percentage"></a>`markup_percentage` | `number` | Optional | Markup percentage applied to usage reports for this user.<br />Example: `20` |


<details class="api-schema-source">
<summary>OpenAPI request schema</summary>


```json
{
  "type": "object",
  "properties": {
    "email": {
      "type": "string",
      "nullable": true,
      "description": "User email address.",
      "example": "alice@example.com"
    },
    "name": {
      "type": "string",
      "nullable": true,
      "description": "User display name.",
      "example": "Alice"
    },
    "metadata": {
      "type": "object",
      "description": "Custom key-value metadata.",
      "example": {
        "plan": "pro",
        "team": "engineering"
      }
    },
    "period_budget": {
      "type": "number",
      "nullable": true,
      "description": "Spending budget per period in USD.",
      "example": 100
    },
    "budget_duration": {
      "type": "string",
      "enum": [
        "daily",
        "weekly",
        "monthly"
      ],
      "description": "Budget renewal period.",
      "example": "monthly"
    },
    "total_budget": {
      "type": "number",
      "nullable": true,
      "description": "Total lifetime spending budget in USD.",
      "example": 1000
    },
    "period_start": {
      "type": "string",
      "format": "date-time",
      "description": "Optional custom budget period start.",
      "example": "2025-12-01T00:00:00Z"
    },
    "period_end": {
      "type": "string",
      "format": "date-time",
      "nullable": true,
      "description": "Optional custom budget period end.",
      "example": "2025-12-31T23:59:59Z"
    },
    "markup_percentage": {
      "type": "number",
      "description": "Markup percentage applied to usage reports for this user.",
      "example": 20
    }
  }
}
```

</details>

##### Example


```json
{
  "name": "Alice",
  "period_budget": 200,
  "budget_duration": "monthly"
}
```


<a id="response"></a>

## Responses

### 200

Updated user details.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| <a id="response.body.id"></a>`id` | `string` | Optional | User identifier. |
| <a id="response.body.name"></a>`name` | `string or null` | Optional | User display name. |
| <a id="response.body.email"></a>`email` | `string or null` | Optional | User email address. |
| <a id="response.body.customer_identifier"></a>`customer_identifier` | `string` | Optional | Your unique identifier for the user. |
| <a id="response.body.environment"></a>`environment` | `string` | Optional | User environment.<br />Allowed: `"prod"`, `"test"` |
| <a id="response.body.total_budget"></a>`total_budget` | `number or null` | Optional | Lifetime spending budget in USD. |
| <a id="response.body.period_budget"></a>`period_budget` | `number or null` | Optional | Current period budget in USD. |
| <a id="response.body.organization_name"></a>`organization_name` | `string or null` | Optional | Owning organization name. |
| <a id="response.body.total_period_usage"></a>`total_period_usage` | `number` | Optional | Usage in the current budget period in USD. |
| <a id="response.body.period_start"></a>`period_start` | `string` | Optional | Start of the current budget period.<br />Format: `date-time` |
| <a id="response.body.period_end"></a>`period_end` | `string or null` | Optional | End of the current budget period.<br />Format: `date-time` |
| <a id="response.body.budget_duration"></a>`budget_duration` | `string` | Optional | Budget renewal period.<br />Allowed: `"daily"`, `"weekly"`, `"monthly"` |
| <a id="response.body.updated_at"></a>`updated_at` | `string` | Optional | Last update timestamp.<br />Format: `date-time` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "User identifier."
    },
    "name": {
      "type": "string",
      "nullable": true,
      "description": "User display name."
    },
    "email": {
      "type": "string",
      "nullable": true,
      "description": "User email address."
    },
    "customer_identifier": {
      "type": "string",
      "description": "Your unique identifier for the user."
    },
    "environment": {
      "type": "string",
      "enum": [
        "prod",
        "test"
      ],
      "description": "User environment."
    },
    "total_budget": {
      "type": "number",
      "nullable": true,
      "description": "Lifetime spending budget in USD."
    },
    "period_budget": {
      "type": "number",
      "nullable": true,
      "description": "Current period budget in USD."
    },
    "organization_name": {
      "type": "string",
      "nullable": true,
      "description": "Owning organization name."
    },
    "total_period_usage": {
      "type": "number",
      "description": "Usage in the current budget period in USD."
    },
    "period_start": {
      "type": "string",
      "format": "date-time",
      "description": "Start of the current budget period."
    },
    "period_end": {
      "type": "string",
      "format": "date-time",
      "nullable": true,
      "description": "End of the current budget period."
    },
    "budget_duration": {
      "type": "string",
      "enum": [
        "daily",
        "weekly",
        "monthly"
      ],
      "description": "Budget renewal period."
    },
    "updated_at": {
      "type": "string",
      "format": "date-time",
      "description": "Last update timestamp."
    }
  }
}
```

</details>

##### Example


```json
{
  "id": "user_123",
  "name": "Alice",
  "email": "john@example.com",
  "customer_identifier": "user_123",
  "environment": "prod",
  "total_budget": 1000,
  "period_budget": 200,
  "organization_name": "Acme Inc",
  "total_period_usage": 45.67,
  "period_start": "2025-12-01T00:00:00Z",
  "period_end": null,
  "budget_duration": "monthly",
  "updated_at": "2025-12-29T10:30:00Z"
}
```


<a id="response.error"></a>

### 400

Validation Error

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `$.<key>` | `string or array<string>` | Map value | - |
| `$.<key> (oneOf 1)` | `string` | Schema variant | - |
| `$.<key> (oneOf 2)` | `array<string>` | Schema variant | - |
| `$.<key> (oneOf 2)[]` | `string` | Array item | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "additionalProperties": {
    "oneOf": [
      {
        "type": "string"
      },
      {
        "type": "array",
        "items": {
          "type": "string"
        }
      }
    ]
  }
}
```

</details>

##### invalidBudget


```json
{
  "period_budget": [
    "period_budget must be >= 0"
  ]
}
```


##### invalidDuration


```json
{
  "budget_duration": [
    "Invalid budget duration, must be one of [('daily', 'daily'), ('weekly', 'weekly'), ('monthly', 'monthly')]"
  ]
}
```


### 403

The API key is missing, invalid or expired.

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Required in parent | - |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "required": [
    "detail"
  ],
  "properties": {
    "detail": {
      "type": "string"
    }
  }
}
```

</details>

##### Example


```json
{
  "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
}
```


### 404

Not Found

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Optional | Example: `"Customer user not found"` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "example": "Customer user not found"
    }
  }
}
```

</details>

### 429

Rate Limited

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Optional | Example: `"Request was throttled. Expected available in 1 second."` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "example": "Request was throttled. Expected available in 1 second."
    }
  }
}
```

</details>

### 500

Internal Server Error

#### application/json


| Field | Type | Requirement | Description and constraints |
| --- | --- | --- | --- |
| `$` | `object` | Body | - |
| `detail` | `string` | Optional | Example: `"Internal server error"` |


<details class="api-schema-source">
<summary>OpenAPI response schema</summary>


```json
{
  "type": "object",
  "properties": {
    "detail": {
      "type": "string",
      "example": "Internal server error"
    }
  }
}
```

</details>

## OpenAPI source

The operation and referenced components below retain the complete OpenAPI definitions, including constraints and examples.

<!-- openapi-operation:start -->
<details class="api-schema-source">
<summary>OpenAPI operation</summary>


```json
{
  "summary": "Update a user",
  "operationId": "updateUser",
  "tags": [
    "Users"
  ],
  "description": "Users are created automatically from usage. Use this endpoint to set budgets or update profile fields after creation.",
  "parameters": [
    {
      "name": "customer_identifier",
      "in": "path",
      "required": true,
      "schema": {
        "type": "string"
      },
      "description": "Your unique identifier for this user."
    },
    {
      "name": "environment",
      "in": "query",
      "schema": {
        "type": "string",
        "enum": [
          "prod",
          "test"
        ]
      },
      "description": "Optional environment filter. If omitted, the backend uses the environment implied by your auth context when applicable.",
      "example": "prod"
    }
  ],
  "requestBody": {
    "required": true,
    "content": {
      "application/json": {
        "schema": {
          "type": "object",
          "properties": {
            "email": {
              "type": "string",
              "nullable": true,
              "description": "User email address.",
              "example": "alice@example.com"
            },
            "name": {
              "type": "string",
              "nullable": true,
              "description": "User display name.",
              "example": "Alice"
            },
            "metadata": {
              "type": "object",
              "description": "Custom key-value metadata.",
              "example": {
                "plan": "pro",
                "team": "engineering"
              }
            },
            "period_budget": {
              "type": "number",
              "nullable": true,
              "description": "Spending budget per period in USD.",
              "example": 100
            },
            "budget_duration": {
              "type": "string",
              "enum": [
                "daily",
                "weekly",
                "monthly"
              ],
              "description": "Budget renewal period.",
              "example": "monthly"
            },
            "total_budget": {
              "type": "number",
              "nullable": true,
              "description": "Total lifetime spending budget in USD.",
              "example": 1000
            },
            "period_start": {
              "type": "string",
              "format": "date-time",
              "description": "Optional custom budget period start.",
              "example": "2025-12-01T00:00:00Z"
            },
            "period_end": {
              "type": "string",
              "format": "date-time",
              "nullable": true,
              "description": "Optional custom budget period end.",
              "example": "2025-12-31T23:59:59Z"
            },
            "markup_percentage": {
              "type": "number",
              "description": "Markup percentage applied to usage reports for this user.",
              "example": 20
            }
          }
        },
        "example": {
          "name": "Alice",
          "period_budget": 200,
          "budget_duration": "monthly"
        }
      }
    }
  },
  "responses": {
    "200": {
      "description": "Updated user details.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "id": {
                "type": "string",
                "description": "User identifier."
              },
              "name": {
                "type": "string",
                "nullable": true,
                "description": "User display name."
              },
              "email": {
                "type": "string",
                "nullable": true,
                "description": "User email address."
              },
              "customer_identifier": {
                "type": "string",
                "description": "Your unique identifier for the user."
              },
              "environment": {
                "type": "string",
                "enum": [
                  "prod",
                  "test"
                ],
                "description": "User environment."
              },
              "total_budget": {
                "type": "number",
                "nullable": true,
                "description": "Lifetime spending budget in USD."
              },
              "period_budget": {
                "type": "number",
                "nullable": true,
                "description": "Current period budget in USD."
              },
              "organization_name": {
                "type": "string",
                "nullable": true,
                "description": "Owning organization name."
              },
              "total_period_usage": {
                "type": "number",
                "description": "Usage in the current budget period in USD."
              },
              "period_start": {
                "type": "string",
                "format": "date-time",
                "description": "Start of the current budget period."
              },
              "period_end": {
                "type": "string",
                "format": "date-time",
                "nullable": true,
                "description": "End of the current budget period."
              },
              "budget_duration": {
                "type": "string",
                "enum": [
                  "daily",
                  "weekly",
                  "monthly"
                ],
                "description": "Budget renewal period."
              },
              "updated_at": {
                "type": "string",
                "format": "date-time",
                "description": "Last update timestamp."
              }
            }
          },
          "example": {
            "id": "user_123",
            "name": "Alice",
            "email": "john@example.com",
            "customer_identifier": "user_123",
            "environment": "prod",
            "total_budget": 1000,
            "period_budget": 200,
            "organization_name": "Acme Inc",
            "total_period_usage": 45.67,
            "period_start": "2025-12-01T00:00:00Z",
            "period_end": null,
            "budget_duration": "monthly",
            "updated_at": "2025-12-29T10:30:00Z"
          }
        }
      }
    },
    "400": {
      "description": "Validation Error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "additionalProperties": {
              "oneOf": [
                {
                  "type": "string"
                },
                {
                  "type": "array",
                  "items": {
                    "type": "string"
                  }
                }
              ]
            }
          },
          "examples": {
            "invalidBudget": {
              "value": {
                "period_budget": [
                  "period_budget must be >= 0"
                ]
              }
            },
            "invalidDuration": {
              "value": {
                "budget_duration": [
                  "Invalid budget duration, must be one of [('daily', 'daily'), ('weekly', 'weekly'), ('monthly', 'monthly')]"
                ]
              }
            }
          }
        }
      }
    },
    "403": {
      "$ref": "#/components/responses/InvalidApiKey"
    },
    "404": {
      "description": "Not Found",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "detail": {
                "type": "string",
                "example": "Customer user not found"
              }
            }
          }
        }
      }
    },
    "429": {
      "description": "Rate Limited",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "detail": {
                "type": "string",
                "example": "Request was throttled. Expected available in 1 second."
              }
            }
          }
        }
      }
    },
    "500": {
      "description": "Internal Server Error",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "properties": {
              "detail": {
                "type": "string",
                "example": "Internal server error"
              }
            }
          }
        }
      }
    }
  },
  "security": [
    {
      "RespanApiKey": []
    },
    {
      "DashboardJwt": []
    }
  ]
}
```

</details>
<!-- openapi-operation:end -->

<!-- openapi-path-item:start -->
<details class="api-schema-source">
<summary>OpenAPI path metadata</summary>


```json
{}
```

</details>
<!-- openapi-path-item:end -->

<!-- openapi-components:start -->
<details class="api-schema-source">
<summary>Referenced OpenAPI components</summary>


```json
{
  "responses": {
    "InvalidApiKey": {
      "description": "The API key is missing, invalid or expired.",
      "content": {
        "application/json": {
          "schema": {
            "type": "object",
            "required": [
              "detail"
            ],
            "properties": {
              "detail": {
                "type": "string"
              }
            }
          },
          "example": {
            "detail": "Your API key is invalid or expired, please check your API key in the platform settings."
          }
        }
      }
    }
  },
  "securitySchemes": {
    "DashboardJwt": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Dashboard JWT",
      "description": "Use a dashboard JWT only for dashboard-authenticated endpoints. Respan API-key endpoints use the respanApiKey auth field instead.",
      "x-fern-bearer": {
        "name": "dashboardJwt",
        "env": "RESPAN_DASHBOARD_JWT"
      }
    },
    "RespanApiKey": {
      "type": "http",
      "scheme": "bearer",
      "bearerFormat": "Respan API key",
      "description": "Use your Respan API key for Respan API authentication. Enter only the Respan API key value; clients send Authorization: Bearer <RESPAN_API_KEY>. For /api/responses, provider credentials such as Perplexity, OpenAI, or Azure OpenAI go in Settings -> Providers or respan_params.credential_override in the request body, not in this authentication field.",
      "x-fern-bearer": {
        "name": "respanApiKey",
        "env": "RESPAN_API_KEY"
      }
    }
  }
}
```

</details>
<!-- openapi-components:end -->
