Create Organization Token
Create an organization-scoped personal access token.
Quick Navigation
Endpoint
POST /api/v1/organizations/{org_id}/tokens
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer <access_token> |
Content-Type | Yes | application/json |
Path Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
org_id | integer | Yes | Organization ID |
Request Body
{
"name": "My Org Token",
"scopes": ["read", "write"],
"expires_in_days": 90
}
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Token name/description |
scopes | array | Yes | Token scopes |
expires_in_days | integer | No | Token expiration in days (optional) |
Note: organization_id is automatically set from the path parameter.
Response
Success (201)
{
"success": true,
"data": {
"id": 1,
"name": "My Org Token",
"token": "pat_abc123def456...",
"scopes": ["read", "write"],
"organization_id": 1,
"expires_at": "2024-04-01T12:00:00Z",
"created_at": "2024-01-01T12:00:00Z",
"message": "Organization-scoped token created successfully"
},
"message": "Organization-scoped token created successfully"
}
Error (403)
{
"success": false,
"error": {
"code": "organization_access_denied",
"message": "User is not a member of this organization"
}
}
Features
- Token is scoped to the specified organization
- Token expiration uses organization settings (access_token_expire_minutes)
- User must be a member of the organization
- Token shown only once at creation
Important Notes
WARNING: Save the token immediately after creation, it won't be shown again!
Example
curl -X POST "https://api.rivergen.com/api/v1/organizations/1/tokens" \
-H "Authorization: Bearer <access_token>" \
-H "Content-Type: application/json" \
-d '{
"name": "My Org Token",
"scopes": ["read", "write"],
"expires_in_days": 90
}'
Related Endpoints
- List Org Tokens - List all org tokens (admin)
- Revoke Org Token - Revoke token