DataPI.

What would you like to understand?

Preparing search…
    All results and search filters →

    Guide

    Authentication and credentials

    How bearer tokens, browser sessions, permissions and origin checks differ, and how to handle secrets safely.

    Two surfaces, two authentication models

    api.datapi.ir is the public machine API. Send a workspace bearer token created in the dashboard. app.datapi.ir/api/v1 is the browser surface; the dashboard sends an HttpOnly session cookie automatically and the Next.js BFF forwards it. A browser session cookie is never accepted as a machine credential, and a machine token should never be embedded in browser code.

    Which header to use

    SurfaceHeaderWhen it is used
    Machine APIAuthorization: Bearer <token>Server-to-server requests to api.datapi.ir
    Browser APICookie: datapi_session=…Same-origin dashboard calls; set by OTP verification
    OTP start/verifyNo credentialPublic browser endpoints, still origin-checked on mutation

    Rules that prevent most integration failures

    • Store the secret once, in a secret manager. The dashboard cannot display it again after creation.
    • Scope credentials to one workspace. Requests are always evaluated against that workspace, never a client-supplied workspace ID.
    • Revoke a credential immediately if it leaks. Revocation is effective for new requests without a redeploy.
    • The session cookie is `datapi_session`: HttpOnly, SameSite=Lax and Path=/, with the Secure flag set wherever the deployment serves HTTPS. Browser code cannot read it, so do not try to copy the cookie into a script.
    • Expect 401 for missing, expired or revoked credentials and 403 for a missing/forbidden browser origin or insufficient permission.

    Never expose provider details

    Related pages

    Runtime contract snapshot: DataPI API v1.0.0 · 75 HTTP operations documented of 265 runtime operations · 40 catalog operations · 11 available at capture. Captured: . Source: https://api.datapi.ir/v1/contracts.