Skip to main content

Store Credentials

Store encrypted credentials for third-party integrations. This endpoint securely saves authentication credentials in the credential vault, supporting 8 different authentication types for various integration scenarios.


Endpoint

Method: POST URL: {{base_url}}/api/v1/credentials


Authentication

This endpoint uses Bearer Token authentication via a JWT (JSON Web Token). The token must be included in the Authorization header. Requires appropriate permissions to manage credentials.


Headers

HeaderDescriptionRequired
AuthorizationBearer token (JWT) for authenticationYes
acceptSpecifies acceptable response formats (application/json)Yes
content-typeMust be application/jsonYes
x-tenantidUUID identifying the tenant/organizationYes
realmnameThe authentication realm nameNo

Path Parameters

None.


Query Parameters

None.


Request Body Schema

FieldTypeDescriptionRequired
integrationIdstringUnique identifier for the integrationYes
credentialNamestringHuman-readable name for the credentialYes
descriptionstringDescription of the credential's purposeNo
expiresInnumberToken expiration time in secondsNo
scopesarrayList of permission scopes for the credentialNo
tokenEndpointstringOAuth token endpoint URLNo
authorizationEndpointstringOAuth authorization endpoint URLNo
metadataobjectAdditional custom properties for the credentialNo
authTypestringAuthentication type (see supported types below)Yes
accessTokenstringThe access token to storeNo
refreshTokenstringThe refresh token to storeNo

Supported Auth Types

Auth TypeDescriptionUse Case
oauth2_bearerOAuth 2.0 Bearer TokenStandard OAuth 2.0 integrations
oauth2_client_credentialsOAuth 2.0 Client CredentialsMachine-to-machine authentication
api_keyAPI Key authenticationSimple API key-based integrations
basic_authBasic AuthenticationUsername/password authentication
bearer_tokenSimple Bearer TokenToken-based authentication
jwtJSON Web TokenJWT-based authentication
samlSAML TokenEnterprise SSO integrations
customCustom authenticationCustom authentication schemes

Request Body Example

{
"integrationId": "string",
"credentialName": "string",
"description": "string",
"expiresIn": 1,
"scopes": [
"string"
],
"tokenEndpoint": "string",
"authorizationEndpoint": "string",
"metadata": {
"additionalProp1": "string",
"additionalProp2": "string",
"additionalProp3": "string"
},
"authType": "oauth2_bearer",
"accessToken": "string",
"refreshToken": "string"
}

OAuth 2.0 Bearer Token Example:

{
"integrationId": "servicenow-prod-001",
"credentialName": "ServiceNow Production",
"description": "OAuth credentials for ServiceNow ITSM production instance",
"expiresIn": 3600,
"scopes": [
"read",
"write",
"admin"
],
"tokenEndpoint": "https://instance.service-now.com/oauth_token.do",
"authorizationEndpoint": "https://instance.service-now.com/oauth_auth.do",
"metadata": {
"environment": "production",
"instanceUrl": "https://instance.service-now.com",
"version": "tokyo"
},
"authType": "oauth2_bearer",
"accessToken": "{{access_token}}",
"refreshToken": "{{refresh_token}}"
}

API Key Example:

{
"integrationId": "slack-workspace-001",
"credentialName": "Slack Bot API Key",
"description": "API key for Slack workspace integration",
"metadata": {
"workspace": "rezolve-workspace",
"botName": "IT Support Bot"
},
"authType": "api_key",
"accessToken": "{{api_key}}"
}

Basic Auth Example:

{
"integrationId": "jira-cloud-001",
"credentialName": "Jira Cloud Credentials",
"description": "Basic auth credentials for Jira Cloud",
"metadata": {
"baseUrl": "https://company.atlassian.net",
"username": "api-user@company.com"
},
"authType": "basic_auth",
"accessToken": "{{base64_encoded_credentials}}"
}

Example cURL

curl --request POST \
--url '{{base_url}}/api/v1/credentials' \
--header 'accept: application/json' \
--header 'authorization: Bearer {{access_token}}' \
--header 'content-type: application/json' \
--header 'x-tenantid: {{tenant_id}}' \
--data '{
"integrationId": "servicenow-prod-001",
"credentialName": "ServiceNow Production",
"description": "OAuth credentials for ServiceNow ITSM production instance",
"expiresIn": 3600,
"scopes": [
"read",
"write"
],
"tokenEndpoint": "https://instance.service-now.com/oauth_token.do",
"authorizationEndpoint": "https://instance.service-now.com/oauth_auth.do",
"metadata": {
"environment": "production"
},
"authType": "oauth2_bearer",
"accessToken": "{{oauth_access_token}}",
"refreshToken": "{{oauth_refresh_token}}"
}'

Success Response Example

Status Code: 200 OK

{
"success": true,
"message": "Credentials stored successfully",
"data": {
"id": "cred-550e8400-e29b-41d4-a716-446655440001",
"integrationId": "servicenow-prod-001",
"credentialName": "ServiceNow Production",
"description": "OAuth credentials for ServiceNow ITSM production instance",
"authType": "oauth2_bearer",
"scopes": [
"read",
"write"
],
"status": "active",
"expiresAt": "2025-07-10T14:15:00.000Z",
"metadata": {
"environment": "production"
},
"createdAt": "2025-07-10T13:15:00.000Z",
"createdBy": {
"id": "1876278a-3634-4833-b73e-1536d806e117",
"name": "Deepak purohit",
"email": "deepak.purohit@rezolve.ai"
},
"tenant": {
"id": "{{tenant_id}}",
"name": "{{tenant_name}}"
}
},
"timestamp": "2025-07-10T13:15:00.000Z"
}
Important

Sensitive credential data (accessToken, refreshToken, secrets) is encrypted at rest and never returned in API responses after initial storage.


Error Responses

Status CodeErrorDescription
400 Bad RequestInvalid request bodyMissing required fields or invalid format
401 UnauthorizedAuthentication failedBearer token is missing, expired, or invalid
403 ForbiddenInsufficient permissionsUser lacks permission to store credentials
409 ConflictDuplicate credentialCredential with this integrationId already exists
422 Unprocessable EntityValidation errorInvalid auth type, endpoint URL, or scope
500 Internal Server ErrorServer errorUnexpected server-side error

Example Error Response:

{
"success": false,
"error": {
"code": "VALIDATION_ERROR",
"message": "Invalid request body",
"details": {
"authType": "Invalid auth type: 'custom_oauth'. Allowed: oauth2_bearer, oauth2_client_credentials, api_key, basic_auth, bearer_token, jwt, saml, custom",
"tokenEndpoint": "Invalid URL format"
}
},
"timestamp": "2025-07-10T13:15:00.000Z"
}

Notes

  1. Encryption: All sensitive credential data (tokens, secrets, passwords) is encrypted using AES-256 encryption before storage.

  2. Token Refresh: For OAuth 2.0 credentials with refresh tokens, the system can automatically refresh expired access tokens.

  3. Expiration Handling: Set expiresIn to configure automatic expiration. Expired credentials are flagged but not deleted.

  4. Metadata Usage: Use the metadata field to store integration-specific configuration like instance URLs, environment info, or version details.

  5. Scopes: Define scopes to document the permissions associated with the stored credentials.

  6. Integration ID: Use a consistent naming convention for integrationId (e.g., {system}-{environment}-{sequence}).

  7. Credential Rotation: Update credentials using the PATCH endpoint before expiration to maintain integration continuity.

  8. Audit Trail: All credential operations are logged for security auditing purposes.

  9. Access Control: Credentials are tenant-isolated and require appropriate roles to access or modify.

  10. Related Endpoints:

    • GET /credentials — List all stored credentials
    • GET /credentials/{credentialId} — Get credential details (metadata only)
    • PATCH /credentials/{credentialId} — Update credential
    • DELETE /credentials/{credentialId} — Delete credential
    • POST /credentials/{credentialId}/rotate — Rotate credential tokens