Auth-Token header on every other call. A token lasts 30 minutes.
Sandbox:
https://staging.ledgersyncappv2.com. Production: https://ledgersyncappv2.com. Each environment has its own logins, so sign in to each with a login created there. Building on v3 instead? It uses API keys; see Authentication.Sign in
POST /api/v2/public/authenticate with the login’s username and password:
The old v2 reference also listed
fromApi, ipAddress and userAgent in the request. Leave them out. fromApi already defaults to true, the value for API sign-ins; set to false, the sign-in follows the web app’s rules instead and can be refused or come back without a token. LedgerSync ignores ipAddress and userAgent and reads both from your request.Sign in with an email address
POST /api/v2/public/authenticate-by-email takes the login’s email address instead of its username:
username tells you the login’s username. It works when exactly one LedgerSync login has that email address. When more than one does, it answers 403 with This email is linked to more than one account. Please sign in with your username, or contact support. Sign in with the username instead.
Send the token
Put theauthToken value in an Auth-Token header on every call outside /api/v2/public/:
/api/v2/public/, such as sign-in and password reset, do not check the header.
How long a token lasts
A token works for 30 minutes from sign-in, and using it does not extend that time. Sign in again before the 30 minutes are up, or as soon as a call answers401, and carry on with the new token.
Signing in again does not end earlier tokens. Several jobs can sign in with the same login at the same time, and each token runs out on its own.
Log out
POST /api/v2/public/logout with the token in the Auth-Token header ends it before its 30 minutes are up:
204 No Content, whatever the token, even one that has already expired. From then on the API answers 401 with User not authorized to perform request! to that token. Logging out is optional: a token also runs out by itself.
The logout request has no body, but it still needs a
Content-Length header: a POST without one is refused with 411 Length Required. curl sends none for a bare -X POST, hence the -H "Content-Length: 0".Errors
When signing in
A refused sign-in comes back in the same shape as a successful one:
403 Forbidden
400 has a different body:
400 Bad Request
4xx status (412, 417 or 426) and a message. Send that message to LedgerSync support.
On every other call
Both bodies are plain text, not JSON. On either one, sign in again and retry with the new token.
