LemuAIDocs

Getting Started · 7 min read

Authentication

Authenticate LemuTickets API requests with a scoped API key or an OAuth app

Open in ChatGPTOpen in ClaudeMarkdown

There are two ways to call the LemuTickets API:

UseWhen
API keyYour own server talks to LemuTickets, for example your ERP syncing tickets. This is the usual choice.
OAuth appYou build an app that acts for a person who approves it (authorization code), or a server integration that should not use a long-lived key (client credentials).

Both are sent as a bearer token in the Authorization header.

API keys, client secrets and access tokens act on your organization's data. Keep them on your server. Never put them in a browser, a mobile app or a public repository. To show tickets in a browser, use an embed token instead.

API keys#

Create a key#

  1. In LemuTickets, open Settings → API keys and webhooks and stay on the API keys tab.
  2. Click Create key.
  3. Fill in the form:
    • Name: where the key is used, for example ERP sync.
    • Mode: Live keys start with ltk_live_, Test keys with ltk_test_. The mode only labels the key; both work on the same organization and data.
    • Scopes: pick a preset (Read only, Agent or Full access) or Custom to choose scopes one by one. See scopes below.
    • Projects: limit the key to some projects. Empty means every project.
    • Requests per minute: the key's rate limit. The default is 600.
    • Allowed IP addresses: single addresses or CIDR ranges the key may be used from. Empty means any address.
    • Expires: never, or on a date you choose.
  4. Copy the key. The full key is shown only once. Store it straight away in a secrets manager or an environment variable.

You need the api_keys.manage permission to see this page (organization owners and admins have it). You cannot give a key a scope you do not have yourself.

To stop a key working, revoke it on the same page. A revoked or expired key is rejected at once.

Send the key#

cURL
curl https://api.tickets.lemuai.com/v1/projects \
  -H "Authorization: Bearer ltk_live_your_api_key"

The X-API-Key: ltk_live_your_api_key header also works.

Who the key acts as#

Each key acts as its own user, named API: followed by the key's name (for example API: ERP sync). Tickets the key creates show this user as the reporter, and comments it writes show it as the author.

A key does not see restricted tickets unless they are shared with that user, and it only sees the projects you chose when you created it.

Scopes#

Scopes are the same permissions team members have. A request that needs a scope the key does not have fails with 403 and the code missing_capability.

ScopeAllows
tickets.readSee tickets in projects the key can access
tickets.writeCreate and edit tickets, comment, transition
tickets.deleteDelete and merge tickets
tickets.assignAssign tickets to others
tickets.bulkBulk update tickets
comments.internalRead and write internal notes
requesters.readSee requesters and accounts
requesters.writeCreate and edit requesters and accounts
pii.readSee unmasked phone numbers and emails
projects.readSee projects
projects.adminCreate projects, edit workflows, types and fields
config.adminSLAs, escalations, automations, assignment, calendars, macros
teams.adminManage teams, skills and shifts
integrations.adminConnect Slack, email, Lemu, Jira and other integrations
api_keys.manageCreate and revoke API keys and webhooks
reports.readSee reports and dashboards
audit.readSee and export the audit log
security.adminRoles, SSO, IP allowlist, retention, sandboxes
data.exportExport and import data
copilot.useUse the Copilot
approvals.decideApprove or reject approval requests
assets.readSee assets
assets.writeCreate and edit assets
field_service.dispatchSchedule and dispatch field visits
kb.writeWrite knowledge base articles

The presets give a key these scopes:

PresetScopes
Read onlytickets.read, requesters.read, projects.read, reports.read
Agenttickets.read, tickets.write, tickets.assign, tickets.bulk, comments.internal, requesters.read, requesters.write, pii.read, projects.read, reports.read, copilot.use, assets.read, assets.write, kb.write
Full accessEvery scope

Without pii.read, emails and phone numbers in responses are partly hidden, for example p•••@example.com and +91•••••••210.

OAuth apps#

Register an OAuth app when someone other than your own server needs access, or when you want short-lived tokens instead of a key.

Register an app#

  1. Open Settings → API keys and webhooks and select the OAuth apps tab.
  2. Click Register app and fill in App name, an optional Logo URL and Description, the Redirect URIs, and the scopes it can ask for.
  3. Leave Can keep a secret on for apps with a server. Turn it off for mobile or single-page apps: they get no client secret and must use PKCE.
  4. Copy the client ID (ltc_...) and, for apps that can keep a secret, the client secret (ltcs_...). The secret is shown only once.

Redirect URIs must match exactly and use https (http is allowed only for localhost).

Authorization code with PKCE#

Use this when your app acts for a LemuTickets user. The token can never do more than that user can do now, and only within the scopes they approved.

1. Send the user to the consent screen. Create a random code_verifier (43 to 128 characters) and its SHA-256 code_challenge (base64url, no padding), then open:

Text
https://tickets.lemuai.com/oauth/authorize
  ?response_type=code
  &client_id=ltc_your_client_id
  &redirect_uri=https://erp.example.com/oauth/callback
  &scope=tickets.read tickets.write
  &state=af0ifjsldkj
  &code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
  &code_challenge_method=S256

The URL is split over lines here to make it easier to read; send it as one line with the values URL-encoded. PKCE with S256 is required for every app. scope is a space-separated list; leave it out to ask for all of the app's scopes. After the user approves, they return to your redirect_uri with code and your state. The code expires after 5 minutes and works once.

2. Exchange the code for tokens:

cURL
curl -X POST https://api.tickets.lemuai.com/v1/oauth/token \
  -u "ltc_your_client_id:ltcs_your_client_secret" \
  -d grant_type=authorization_code \
  -d code=ltac_code_from_the_redirect \
  -d redirect_uri=https://erp.example.com/oauth/callback \
  -d code_verifier=your_code_verifier

Apps without a secret send client_id in the body instead of -u, and no secret.

JSON
{
  "access_token": "lto_9kq2...",
  "token_type": "Bearer",
  "expires_in": 3600,
  "scope": "tickets.read tickets.write",
  "refresh_token": "ltr_X4b7..."
}

3. Call the API with Authorization: Bearer lto_.... Access tokens last 1 hour.

4. Refresh before the access token expires. Refresh tokens last 30 days and change every time you use one: store the new one each time. Using an old refresh token again ends the whole grant, and the user has to approve the app again.

cURL
curl -X POST https://api.tickets.lemuai.com/v1/oauth/token \
  -u "ltc_your_client_id:ltcs_your_client_secret" \
  -d grant_type=refresh_token \
  -d refresh_token=ltr_X4b7...

You can send a smaller scope when refreshing, but not a wider one.

Client credentials#

Use this for a server integration that acts for your organization, not for a person. It needs an app that can keep a secret.

cURL
curl -X POST https://api.tickets.lemuai.com/v1/oauth/token \
  -u "ltc_your_client_id:ltcs_your_client_secret" \
  -d grant_type=client_credentials \
  -d "scope=tickets.read tickets.write"

The response has an access_token that lasts 1 hour and no refresh token: ask for a new one when it expires. Leave out scope to get all of the app's scopes.

A client credentials token is not tied to a user, so endpoints that record a person need one in the request. For example, Log work needs user_id.

Token endpoint details#

Token URLPOST https://api.tickets.lemuai.com/v1/oauth/token
Revoke URLPOST https://api.tickets.lemuai.com/v1/oauth/revoke with token=...
Client authenticationHTTP Basic (client_secret_basic), or client_id and client_secret in the body (client_secret_post)
Body formatapplication/x-www-form-urlencoded or JSON
Server metadatahttps://api.tickets.lemuai.com/.well-known/oauth-authorization-server

Token endpoint errors use the OAuth format, not the API's usual error shape:

JSON
{
  "error": "invalid_grant",
  "error_description": "The code expired"
}
errorMeaning
invalid_clientUnknown client, wrong secret, or a secret sent for an app that has none (401)
invalid_grantThe code or refresh token is unknown, used, expired or revoked, or the PKCE check or redirect_uri does not match
invalid_scopeThe app may not ask for these scopes
unauthorized_clientClient credentials asked for by an app without a secret
unsupported_grant_typegrant_type is not authorization_code, refresh_token or client_credentials

Removing an app in Settings → API keys and webhooks revokes all of its tokens.

Authentication errors#

StatusCodeMeaning
401unauthenticatedNo key or token was sent
401invalid_api_keyThe key is wrong, revoked or expired
401invalid_tokenThe OAuth access token is wrong, revoked or expired, or the app was removed
403ip_not_allowedThe request came from an IP address the key, or your organization, does not allow
403missing_capabilityThe key or token does not have the scope this endpoint needs
JSON
{
  "error": {
    "type": "unauthorized",
    "code": "invalid_api_key",
    "message": "Invalid API key",
    "request_id": "4f1d9c2b7a6e4e0f8c3b1a2d5e6f7a8b"
  }
}

Was this page helpful?