Skip to main content

Update API Key

Update an existing API key. Users can only update their own API keys.
path
integer
required
API key ID

Request Body

object
required
API key object with fields to update
string
Descriptive name for the key
array
Array of allowed CORS origins
array
Array of assistant IDs the key can access
curl -X PUT "https://api.example.com/api/v1/api_keys/1" \
  -H "X-API-Key: your-api-key-here" \
  -H "Content-Type: application/json" \
  -d '{
    "api_key": {
      "name": "Updated Production Key",
      "allowed_origins": ["https://example.com", "https://app.example.com"],
      "allowed_assistants": ["123", "456"]
    }
  }'

Response

status
object
Response status information
code
integer
HTTP status code (200)
message
string
Status message
data
object
Updated API key object
{
  "status": {
    "code": 200,
    "message": "API key updated successfully"
  },
  "data": {
    "id": 1,
    "key_type": "private",
    "name": "Updated Production Key",
    "key_value": null,
    "allowed_origins": ["https://example.com", "https://app.example.com"],
    "allowed_assistants": ["123", "456"],
    "transient_assistant": false,
    "user_id": 1,
    "user_email": "[email protected]",
    "created_at": "2024-01-10T08:00:00Z",
    "updated_at": "2024-01-15T11:00:00Z"
  }
}

Error Responses

401
object
Unauthorized - Invalid or missing authentication
404
object
API key not found
422
object
Validation error - Invalid request body