Tokens
Create a new access token
Create a new access token for either account-wide or project-specific access. Project tokens require a valid project slug.
Authorization
Authorization
header
string
required
Enter the team access token with the Bearer prefix, e.g. "Bearer team_access_token"
Bodyapplication/json
Token creation parameters
Scope specifies the scope of the token, which must be either "team" or "project".
Available options:
projectteam
Name is the name of the token, which can be up to 64 characters long.
ProjectId is required if the scope is set to "project".
Examples:
proj_A1cce6120E56e7Tu9ioP09Nhjk1
Responses
application/jsonData contains the response object
created_at
string
date-time
required
Timestamp when the token was created
Examples:
2025-01-01T12:00:00Z
Unique identifier of the token
Examples:
tok_2G6MJiNz71bHQGNzGwKx5cJwPFS
Examples:
Production API Key
ID of the project this token belongs to
Examples:
proj_A1cce6120E56e7Tu9ioP09Nhjk1
Access scope of the token
Available options:
projectteam
The actual token value (only returned on creation)
status
"success"
string
required
Status indicates the response status "success"
The token was created successfully
application/jsonCode is the HTTP status code
Message is a human-readable error description
Examples:
Invalid request parameters
type
"ValidationError"
string
required
Type indicates the error category
Available options:
ValidationError
status
"error"
string
required
Status indicates the response status "error"
Invalid request parameters
application/jsonError response details
Code is the HTTP status code
Message is a human-readable error description
Examples:
Authentication error: invalid token or subscription inactive
type
"AuthenticationError"
string
required
Type indicates the error category
Available options:
AuthenticationError
status
"error"
string
required
Status indicates the response status "error"
Authentication error: invalid token or subscription inactive
application/jsonError response details
Code is the HTTP status code
Message is a human-readable error description
Examples:
Rate limit exceeded
type
"TooManyRequestsError"
string
required
Type indicates the error category
Available options:
TooManyRequestsError
status
"error"
string
required
Status indicates the response status "error"
Rate limit exceeded
# Create a new access token
> Create a new access token for either account-wide or project-specific access. Project tokens require a valid project slug.
```json
{
"path": "/api/tokens",
"method": "post",
"schema": {
"description": "Create a new access token for either account-wide or project-specific access. Project tokens require a valid project slug.",
"operationId": "createToken",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenCreateParams"
}
}
},
"description": "Token creation parameters",
"required": true,
"x-originalParamName": "request"
},
"responses": {
"201": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/TokenResponse"
}
}
},
"description": "The token was created successfully"
},
"400": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ResponseErrorValidation"
}
}
},
"description": "Invalid request parameters"
},
"401": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ResponseErrorAuthentication"
}
}
},
"description": "Authentication error: invalid token or subscription inactive"
},
"429": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ResponseErrorTooManyRequests"
}
}
},
"description": "Rate limit exceeded"
}
},
"security": [
{
"TeamAccessToken": []
}
],
"summary": "Create a new access token",
"tags": [
"Tokens"
],
"x-codeSamples": [
{
"lang": "JavaScript",
"source": "import Chunkify from '@chunkify/chunkify';\n\nconst client = new Chunkify({\n teamAccessToken: 'My Team Access Token',\n});\n\nconst token = await client.tokens.create({ scope: 'project' });\n\nconsole.log(token);"
},
{
"lang": "Python",
"source": "from chunkify import Chunkify\n\nclient = Chunkify(\n team_access_token=\"My Team Access Token\",\n)\ntoken = client.tokens.create(\n scope=\"project\",\n)\nprint(token)"
},
{
"lang": "php",
"source": "\u003c?php\n\nuse Chunkify\\Client;\n\n$client = new Client(\n teamAccessToken: 'My Team Access Token',\n);\n\n$token = $client-\u003etokens-\u003ecreate(scope: 'project');\n\nvar_dump($token);"
},
{
"lang": "Go",
"source": "package main\n\nimport (\n \"context\"\n \"fmt\"\n\n \"github.com/chunkifydev/chunkify-go\"\n \"github.com/chunkifydev/chunkify-go/option\"\n)\n\nfunc main() {\n client := chunkify.NewClient(\n option.WithTeamAccessToken(\"My Team Access Token\"),\n )\n token, err := client.Tokens.New(context.TODO(), chunkify.TokenNewParams{\n Scope: chunkify.TokenNewParamsScopeProject,\n })\n if err != nil {\n panic(err.Error())\n }\n fmt.Printf(\"%+v\\n\", token)\n}\n"
}
]
}
}
```
```json #/components/schemas/TokenCreateParams
{
"if": {
"properties": {
"scope": {
"const": "project"
}
}
},
"properties": {
"name": {
"description": "Name is the name of the token, which can be up to 64 characters long.",
"examples": [
"My Token"
],
"maxLength": 64,
"type": "string"
},
"project_id": {
"description": "ProjectId is required if the scope is set to \"project\".",
"examples": [
"proj_A1cce6120E56e7Tu9ioP09Nhjk1"
],
"type": "string"
},
"scope": {
"$ref": "#/components/schemas/TokenScope",
"description": "Scope specifies the scope of the token, which must be either \"team\" or \"project\"."
}
},
"required": [
"scope"
],
"then": {
"required": [
"project_id"
]
},
"type": "object"
}
```
```json #/components/schemas/TokenScope
{
"enum": [
"project",
"team"
],
"type": "string"
}
```
```json #/components/schemas/TokenResponse
{
"properties": {
"data": {
"$ref": "#/components/schemas/Token",
"description": "Data contains the response object"
},
"status": {
"const": "success",
"description": "Status indicates the response status \"success\"",
"type": "string"
}
},
"required": [
"status",
"data"
],
"type": "object"
}
```
```json #/components/schemas/Token
{
"properties": {
"created_at": {
"description": "Timestamp when the token was created",
"examples": [
"2025-01-01T12:00:00Z"
],
"format": "date-time",
"type": "string"
},
"id": {
"description": "Unique identifier of the token",
"examples": [
"tok_2G6MJiNz71bHQGNzGwKx5cJwPFS"
],
"type": "string"
},
"name": {
"description": "Name given to the token",
"examples": [
"Production API Key"
],
"type": "string"
},
"project_id": {
"description": "ID of the project this token belongs to",
"examples": [
"proj_A1cce6120E56e7Tu9ioP09Nhjk1"
],
"type": "string"
},
"scope": {
"$ref": "#/components/schemas/TokenScope",
"description": "Access scope of the token"
},
"token": {
"description": "The actual token value (only returned on creation)",
"examples": [
"sk_project..."
],
"type": "string"
}
},
"required": [
"id",
"name",
"project_id",
"scope",
"token",
"created_at"
],
"type": "object"
}
```
```json #/components/schemas/TokenScope
{
"enum": [
"project",
"team"
],
"type": "string"
}
```
```json #/components/schemas/ResponseErrorValidation
{
"properties": {
"error": {
"properties": {
"code": {
"const": 400,
"description": "Code is the HTTP status code",
"examples": [
400
],
"type": "integer"
},
"message": {
"description": "Message is a human-readable error description",
"examples": [
"Invalid request parameters"
],
"type": "string"
},
"type": {
"const": "ValidationError",
"description": "Type indicates the error category",
"enum": [
"ValidationError"
],
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
},
"status": {
"const": "error",
"description": "Status indicates the response status \"error\"",
"type": "string"
}
},
"required": [
"status",
"error"
]
}
```
```json #/components/schemas/ResponseErrorAuthentication
{
"description": "Error response",
"properties": {
"error": {
"description": "Error response details",
"properties": {
"code": {
"const": 401,
"description": "Code is the HTTP status code",
"examples": [
401
],
"type": "integer"
},
"message": {
"description": "Message is a human-readable error description",
"examples": [
"Authentication error: invalid token or subscription inactive"
],
"type": "string"
},
"type": {
"const": "AuthenticationError",
"description": "Type indicates the error category",
"enum": [
"AuthenticationError"
],
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
},
"status": {
"const": "error",
"description": "Status indicates the response status \"error\"",
"type": "string"
}
},
"required": [
"status",
"error"
],
"type": "object"
}
```
```json #/components/schemas/ResponseErrorTooManyRequests
{
"description": "Error response",
"properties": {
"error": {
"description": "Error response details",
"properties": {
"code": {
"const": 429,
"description": "Code is the HTTP status code",
"examples": [
429
],
"type": "integer"
},
"message": {
"description": "Message is a human-readable error description",
"examples": [
"Rate limit exceeded"
],
"type": "string"
},
"type": {
"const": "TooManyRequestsError",
"description": "Type indicates the error category",
"enum": [
"TooManyRequestsError"
],
"type": "string"
}
},
"required": [
"type",
"code",
"message"
],
"type": "object"
},
"status": {
"const": "error",
"description": "Status indicates the response status \"error\"",
"type": "string"
}
},
"required": [
"status",
"error"
],
"type": "object"
}
```