Skip to content

API Authentication

DocSpring uses API tokens for authentication. You can authenticate using HTTP basic authentication. Use your API token ID as the username, and the API token secret as the password.

All DocSpring API clients support authentication via environment variables. Set the following environment variables, and the client will automatically use them:

  • DOCSPRING_TOKEN_ID - Your API token ID
  • DOCSPRING_TOKEN_SECRET - Your API token secret

This allows you to keep your credentials out of your code:

Terminal window
export DOCSPRING_TOKEN_ID="your_token_id"
export DOCSPRING_TOKEN_SECRET="your_token_secret"

Then initialize the client without passing credentials:

# Ruby
client = DocSpring::Client.new # Automatically uses ENV variables
# JavaScript/TypeScript
const client = new DocSpring.Client(); // Automatically uses process.env
# Python
client = docspring.Client() # Automatically uses os.environ

“HTTP basic authentation” means that you need to send an Authorization header with the value Basic followed by token_id:token_secret in Base64 encoding.

Some tools such as curl can create the Authorization header for you:

Terminal window
curl -u API_TOKEN_ID:API_TOKEN_SECRET \
https://sync.api.docspring.com/api/v1/authentication

Or you can create the Base64 encoded string manually:

Terminal window
# echo -n "API_TOKEN_ID:API_TOKEN_SECRET" | base64
QVBJX1RPS0VOX0lEOkFQSV9UT0tFTl9TRUNSRVQ=
curl -H "Authorization: Basic QVBJX1RPS0VOX0lEOkFQSV9UT0tFTl9TRUNSRVQ=" \
https://sync.api.docspring.com/api/v1/authentication