Skip to main content

Get or create API key for user

POST /api/service/users/{user_id}/orgs/{org_id}/api-keys

Get or create an API key for a user on behalf of the automations service. If a key with the given name already exists for the user/org and is not expired, returns the existing key. Otherwise, creates a new key. The created/returned keys are system keys and are: - Not visible to the user in their API keys list - Not deletable by the user - Never expire Args: user_id: The user ID org_id: The organization ID request: Request body containing name (required) x_service_api_key: Service API key header for authentication Returns: CreateUserApiKeyResponse: The API key and metadata Raises: HTTPException: 401 if service key is invalid HTTPException: 404 if user not found HTTPException: 403 if user is not a member of the specified org

Parameters

NameInTypeRequiredDescription
user_idpathstringyes
org_idpathstringyes
X-Service-API-Keyheader`stringnull`no

Request body

FieldTypeRequiredDescription
namestringyes

Responses

StatusDescription
200Successful Response
422Validation Error

Response body

FieldTypeRequiredDescription
keystringyes
user_idstringyes
org_idstringyes
namestringyes

Operation ID: get_or_create_api_key_for_user_api_service_users__user_id__orgs__org_id__api_keys_post