Getting started
Create a database token
Issue a connection token and return its secret once. Save its ID if you need to revoke it later.
POST
/api/customer/v1/projects/{projectId}/databases/{databaseId}/tokensThis operation can remove, overwrite or interrupt resources, or grant access. Check the project and resource IDs before sending it.
Path parameters
| Name | Value |
|---|---|
projectId | Required resource ID from an earlier API response. |
databaseId | Required resource ID from an earlier API response. |
Request body
Send JSON with Content-Type: application/json. Nested fields and accepted values are listed in the schema.
| Field | Type | Required |
|---|---|---|
label | string | No |
expiresIn | "1h" | "24h" | "7d" | "30d" | "never" | Yes |
Full request schema
{
"type": "object",
"properties": {
"label": {
"type": "string"
},
"expiresIn": {
"type": "string",
"enum": [
"1h",
"24h",
"7d",
"30d",
"never"
]
}
},
"required": [
"expiresIn"
],
"additionalProperties": false
}Example request
Set HCODE_BASE_URL and HCODE_API_KEY as shown in Getting started. Replace resource variables with your own IDs.
curl --request POST "$HCODE_BASE_URL/api/customer/v1/projects/${PROJECT_ID}/databases/${DATABASE_ID}/tokens" \
--header "Authorization: Bearer $HCODE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"expiresIn": "1h"
}' Response
The JSON shape is defined in the response schema.
Response schema
{
"type": "object",
"properties": {
"success": {
"type": "boolean"
},
"token": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"rawToken": {
"type": "string"
},
"label": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"expiresAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"createdAt": {
"anyOf": [
{
"type": "string"
},
{
"type": "null"
}
]
},
"isPermanent": {
"type": "boolean"
}
},
"required": [
"id"
],
"additionalProperties": true
},
"externalConnectionString": {
"type": "string"
},
"operationId": {
"type": "string"
},
"operations": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"status": {
"type": "string"
},
"href": {
"type": "string"
}
},
"required": [
"id",
"status",
"href"
]
}
}
},
"required": [
"success",
"token"
],
"additionalProperties": true
}See errors and retries for failure responses.