Authentication πŸ”

This API supports authentication for two different kinds of use cases:

  • Server-to-server - backend systems, admin portals, etc.

  • End User - a patient or clinician most likely on mobile or the web.

Jump down to example authentication patterns

Server-to-server

CardScan.ai authenticates server-to-server (S2S) API requests using your account's API keys. A request without an API key, or with an expired, or revoked key, will cause the API to return an error.

Every account has separate keys for testing on our sandbox, or for running live in production. The sandbox API is identical to the production API.

API Keys

Your API Keys are available on the Dashboard. The API Keys start with a prefix to clearly distinguish their usage.

For accessing the API in the sandbox environment use keys with this format:

  • sk_test_cardscan_ai_XXXXXXXXXXXXXXX

When you are ready for production or live mode, use keys with this format:

  • sk_live_cardscan_ai_XXXXXXXXXXXXXXX

Note: Legacy API keys in the format secret_test_ and secret_live_ are still supported but new keys use the sk_test_cardscan_ai_ and sk_live_cardscan_ai_ format.

Read more about sandbox vs live mode on the API Endpoints page

End User

End users on all platforms (web, mobile, etc) authenticate with the Cardscan.ai APIs using a sessionToken. This token is a short-lived JSON Web Token (JWT).

Requesting a token is done via the Access Token endpoint.

By default end users lose access to uploaded cards and all associated data when their session token expires. To prevent this pass in a user_id as a query parameter to the /access-token endpoint. The user_id parameter must be unique across your user base, we recommend using an email address or internal uuid identifier.

Server-to-server requests continue to have access to uploaded cards and associated data, even after the end user's session has expired.

Authentication Pattern

The recommended pattern for authenticating end users is to create a CardScan.ai authentication endpoint on the customer's backend servers. In the diagram below the endpoint is called /cardscan-session and is responsible for authenticating the end user before requesting a session token from the CardScan.ai API.

Auth Diagram

Below are two overly simplified examples of this workflow for Flask and Express:

Once a session has been generated, it can be used to initialize the SDK and UI Components, or used to call the API directly. This allows the end user's browser or mobile device to safely and securely connect with the CardScan.ai servers.

Last updated

Was this helpful?