Skip to main content
POST
/
credentials
from dari import Dari

client = Dari(api_key="YOUR_API_KEY")

credential = client.create_credential(
    service_name="Gmail",
    username_or_email="user@example.com",
    password="mypassword",
    totp_secret="JBSWY3DPEHPK3PXP"
)

print(f"Created credential: {credential['id']}")
{
  "id": "credential-uuid",
  "service_name": "Gmail",
  "username_or_email": "user@example.com",
  "has_password": true,
  "has_totp": true,
  "has_gmail_oauth": false,
  "has_phone_number": false,
  "created_at": "2025-11-09T22:31:40.266578",
  "updated_at": "2025-11-09T22:31:40.266580"
}
This endpoint allows you to create a new credential that can be used by workflows to authenticate with external services. Supports username/password, OAuth, TOTP, and phone number authentication methods.

Headers

X-API-Key
string
required
Your API key for authentication

Request Body

service_name
string
required
The name of the service this credential is for (e.g., “Gmail”, “Slack”)
username_or_email
string
The username or email associated with this credential
password
string
The password for this credential. Will be encrypted with Fernet encryption.
totp_secret
string
TOTP secret for two-factor authentication. Automatically creates a TOTP key when provided.
gmail_oauth_account_id
string
UUID of the Gmail OAuth account to link to this credential
phone_number_id
string
UUID of the phone number to use for SMS-based 2FA

Response Fields

id
string
The unique identifier of the created credential
service_name
string
The name of the service this credential is for
username_or_email
string
The username or email associated with this credential
has_password
boolean
Whether this credential has a password set
has_totp
boolean
Whether this credential has TOTP 2FA configured
has_gmail_oauth
boolean
Whether this credential has Gmail OAuth linked
has_phone_number
boolean
Whether this credential has a phone number for SMS 2FA
created_at
string
ISO 8601 timestamp of when the credential was created
updated_at
string
ISO 8601 timestamp of when the credential was last updated
from dari import Dari

client = Dari(api_key="YOUR_API_KEY")

credential = client.create_credential(
    service_name="Gmail",
    username_or_email="user@example.com",
    password="mypassword",
    totp_secret="JBSWY3DPEHPK3PXP"
)

print(f"Created credential: {credential['id']}")
{
  "id": "credential-uuid",
  "service_name": "Gmail",
  "username_or_email": "user@example.com",
  "has_password": true,
  "has_totp": true,
  "has_gmail_oauth": false,
  "has_phone_number": false,
  "created_at": "2025-11-09T22:31:40.266578",
  "updated_at": "2025-11-09T22:31:40.266580"
}

Features

  • Encryption: Passwords are encrypted using Fernet encryption for security
  • TOTP Support: Automatically creates TOTP keys when totp_secret is provided
  • Multiple Auth Methods: Supports username/password, OAuth, TOTP, and phone number authentication
  • Workspace Scoped: Credentials are scoped to your workspace and membership is validated

Usage Notes

  • API Key: Get your API key from the Dari dashboard in workspace settings
  • Security: Passwords are encrypted and never stored in plain text
  • Flexibility: You can provide any combination of authentication methods based on your needs
  • Validation: The system validates that you’re a member of the workspace before creating credentials

Error Responses

{
  "detail": "Invalid API key"
}
{
  "detail": "Not a member of this workspace"
}
{
  "detail": "Failed to create credential"
}