Amigo API Keys API
The API Keys API from Amigo — 4 operation(s) for api keys.
The API Keys API from Amigo — 4 operation(s) for api keys.
openapi: 3.1.0
info:
title: Amigo Account API Keys API
version: 0.1.0
servers:
- url: https://api.amigo.ai
- url: https://internal-api.amigo.ai
- url: https://api-eu-central-1.amigo.ai
- url: https://api-ap-southeast-2.amigo.ai
- url: https://api-ca-central-1.amigo.ai
security:
- Bearer-Authorization: []
Bearer-Authorization-Organization: []
Basic: []
tags:
- name: API Keys
paths:
/v1/{workspace_id}/api-keys:
post:
tags:
- API Keys
summary: Create an API key
description: Create a new API key for a workspace. The response includes the plaintext `api_key` — store it securely, it cannot be retrieved again.
operationId: create-api-key
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/CreateApiKeyRequest'
responses:
'201':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateApiKeyResponse'
'403':
description: Insufficient permissions or requested role exceeds caller access.
'422':
description: Invalid request body or role.
'401':
description: Missing or invalid API key.
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
format: uuid
title: Workspace Id
get:
tags:
- API Keys
summary: List API keys
description: List all API keys for a workspace with pagination. Requires `ApiKey.view` permission.
operationId: list-api-keys
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
format: uuid
title: Workspace Id
- name: mine_only
in: query
required: false
schema:
type: boolean
default: false
title: Mine Only
- name: limit
in: query
required: false
schema:
type: integer
maximum: 100
exclusiveMinimum: 0
default: 10
title: Limit
- name: continuation_token
in: query
required: false
schema:
type: integer
default: 0
title: Continuation Token
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/PaginatedResponse_ApiKeyResponse_'
'403':
description: Insufficient permissions.
'401':
description: Missing or invalid API key.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/v1/{workspace_id}/api-keys/permission-catalog:
get:
tags:
- API Keys
summary: Get the API-key role/permission catalog
description: 'Return the authoritative role→permission model: each role''s default permission set (what an API key of that role may carry) plus the full permission universe. Clients use this to build the create-key form instead of hard-coding the matrix. Requires `ApiKey.view` permission.'
operationId: get-api-key-permission-catalog
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/PermissionCatalogResponse'
'403':
description: Insufficient permissions.
'401':
description: Missing or invalid API key.
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
format: uuid
title: Workspace Id
/v1/{workspace_id}/api-keys/{key_id}:
delete:
tags:
- API Keys
summary: Delete an API key
description: Revoke an API key. Requires `ApiKey.delete` permission.
operationId: delete-api-key
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
format: uuid
title: Workspace Id
- name: key_id
in: path
required: true
schema:
type: string
title: Key Id
responses:
'204':
description: Successful Response
'404':
description: API key not found.
'403':
description: Insufficient permissions.
'401':
description: Missing or invalid API key.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
/v1/{workspace_id}/api-keys/{key_id}/rotate:
post:
tags:
- API Keys
summary: Rotate an API key
description: Replace an API key secret in one step. The old secret stops working immediately, and the response includes the new plaintext `api_key` exactly once.
operationId: rotate-api-key
parameters:
- name: workspace_id
in: path
required: true
schema:
type: string
format: uuid
title: Workspace Id
- name: key_id
in: path
required: true
schema:
type: string
title: Key Id
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/RotateApiKeyRequest'
responses:
'200':
description: Successful Response
content:
application/json:
schema:
$ref: '#/components/schemas/CreateApiKeyResponse'
'404':
description: API key not found.
'403':
description: Insufficient permissions.
'401':
description: Missing or invalid API key.
'422':
description: Validation Error
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPValidationError'
components:
schemas:
NameString:
type: string
maxLength: 256
minLength: 1
HTTPValidationError:
properties:
detail:
items:
$ref: '#/components/schemas/ValidationError'
type: array
title: Detail
type: object
title: HTTPValidationError
CreateApiKeyResponse:
properties:
key_id:
type: string
title: Key Id
api_key:
type: string
title: Api Key
name:
anyOf:
- type: string
- type: 'null'
title: Name
role:
type: string
title: Role
permissions:
items:
type: string
type: array
title: Permissions
expires_at:
type: string
format: date-time
title: Expires At
created_by_entity_id:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Created By Entity Id
created_by_credential_id:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Created By Credential Id
type: object
required:
- key_id
- api_key
- name
- role
- permissions
- expires_at
- created_by_entity_id
- created_by_credential_id
title: CreateApiKeyResponse
RoleEntry:
properties:
name:
type: string
title: Name
priority:
type: integer
title: Priority
description:
type: string
title: Description
permission_names:
items:
type: string
type: array
title: Permission Names
type: object
required:
- name
- priority
- description
- permission_names
title: RoleEntry
CreateApiKeyRequest:
properties:
name:
anyOf:
- $ref: '#/components/schemas/NameString'
- type: 'null'
duration_days:
type: integer
maximum: 90.0
minimum: 1.0
title: Duration Days
role:
type: string
maxLength: 64
title: Role
default: member
permissions:
items:
type: string
type: array
maxItems: 128
title: Permissions
description: Permission names. Max 128 entries; each entry up to 128 chars.
type: object
required:
- duration_days
title: CreateApiKeyRequest
ValidationError:
properties:
loc:
items:
anyOf:
- type: string
- type: integer
type: array
title: Location
msg:
type: string
title: Message
type:
type: string
title: Error Type
input:
title: Input
ctx:
type: object
title: Context
type: object
required:
- loc
- msg
- type
title: ValidationError
RotateApiKeyRequest:
properties:
duration_days:
type: integer
maximum: 90.0
minimum: 1.0
title: Duration Days
type: object
required:
- duration_days
title: RotateApiKeyRequest
PermissionCatalogResponse:
properties:
roles:
items:
$ref: '#/components/schemas/RoleEntry'
type: array
title: Roles
permissions:
items:
$ref: '#/components/schemas/PermissionEntry'
type: array
title: Permissions
type: object
required:
- roles
- permissions
title: PermissionCatalogResponse
description: 'The authoritative role→permission model for API-key creation.
Serves the server-side source of truth (``DEFAULT_ROLE_DEFINITIONS``) so
clients (console, SDK) stop hand-copying the matrix and drifting out of
sync — a drift previously shipped `Data:Query` as a viewer default and
made the default create flow 422. Human-facing labels/descriptions for
individual permissions stay client-side (pure presentation); this payload
is authorization truth only.'
PaginatedResponse_ApiKeyResponse_:
properties:
items:
items:
$ref: '#/components/schemas/ApiKeyResponse'
type: array
title: Items
has_more:
type: boolean
title: Has More
continuation_token:
anyOf:
- type: integer
- type: 'null'
title: Continuation Token
total:
anyOf:
- type: integer
- type: 'null'
title: Total
type: object
required:
- items
- has_more
title: PaginatedResponse[ApiKeyResponse]
PermissionEntry:
properties:
name:
type: string
title: Name
namespace:
type: string
title: Namespace
action:
type: string
title: Action
type: object
required:
- name
- namespace
- action
title: PermissionEntry
ApiKeyResponse:
properties:
id:
type: string
format: uuid
title: Id
workspace_id:
type: string
format: uuid
title: Workspace Id
created_by_entity_id:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Created By Entity Id
created_by_credential_id:
anyOf:
- type: string
format: uuid
- type: 'null'
title: Created By Credential Id
key_id:
type: string
title: Key Id
name:
anyOf:
- type: string
- type: 'null'
title: Name
role:
type: string
title: Role
permissions:
items:
type: string
type: array
title: Permissions
expires_at:
type: string
format: date-time
title: Expires At
last_used_at:
anyOf:
- type: string
format: date-time
- type: 'null'
title: Last Used At
created_at:
type: string
format: date-time
title: Created At
updated_at:
type: string
format: date-time
title: Updated At
type: object
required:
- id
- workspace_id
- created_by_entity_id
- created_by_credential_id
- key_id
- name
- role
- permissions
- expires_at
- last_used_at
- created_at
- updated_at
title: ApiKeyResponse
securitySchemes:
Bearer-Authorization:
type: http
scheme: bearer
bearerFormat: JWT
description: Amigo issued JWT token that identifies an user. It's issued either after logging in through the frontend, or manually through the [`SignInWithAPIKey`](sign-in-with-api-key) endpoint.
Bearer-Authorization-Organization:
type: apiKey
in: header
name: X-ORG-ID
description: An optional organization identifier that indicates from which organization the token is issued. This is used in rare cases where the user to authenticate is making a request for resources in another organization.
Basic:
type: http
scheme: basic
description: The username should be set to {org_id}_{user_id}, and the password should be the Amigo issued JWT token that identifies the user.