API Keys
Personal access tokens that let external systems act as a user against the mobility API.
API Keys
An API key in Yipii Mobility is a personal access token scoped to your user account and your current tenant. External systems — a warehouse MES, a custom dashboard, an integration script — use a key to authenticate against /api/{tenant}/... endpoints and act as you, subject to the same role and permission checks you have in the UI.
How they compare to session auth
| Session (UI) | API Key | |
|---|---|---|
| How it's presented | HTTP cookie after login | Authorization: Bearer <token> header |
| Lifetime | Until logout or session timeout | Until you revoke it |
| 2FA required | Yes (once 2FA lands) | No — revoke the key to disable |
| Attribution | causer_id = your user | causer_id = your user |
| Refreshable | No — log in again | No — create a new one |
| Abilities/scopes | All your permissions | Subset you choose at creation |
Creating a key
-
Developer Settings → API Keys from the sidebar (the Developer section is visible when you have at least the
adminrole). -
Create key.
-
Name — a human label, e.g.
Warehouse PO sync. Shown in the list and in the audit log. -
Abilities — optional list of scopes. Leave empty for "full access, whatever the user can do." Commonly used scopes:
read:assetswrite:work-ordersread:fuel-logswrite:odometer-entries
The backend enforces scopes via
$request->user()->tokenCan('ability')— any endpoint that matters calls this. If you forget to declare a scope the endpoint needs, requests with the token will 403. -
Expiry — optional. Leave blank for "never expires." Set a concrete date for contractor access or one-off imports.
-
Save.
The plaintext token is shown exactly once on the next screen. It's not stored — the database only keeps a hashed copy. Copy it, paste it into your consuming system, and dismiss the dialog. If you lose it, revoke and create a new one.
Treat API keys like passwords. Anyone with the token can do everything the token's scopes allow, attributed as you. Don't commit them to git. Don't email them. Consider one-key-per-integration so individual keys can be revoked without breaking everything.
Using a key
Every request needs the token in the Authorization header:
Keys are tenant-bound: the token is issued against the tenant you were inside when you created it. A token for the acme tenant cannot be used against globex — the URL prefix must match.
Revoking
From Developer Settings → API Keys, click Revoke on any row. The row is soft-deleted and the hashed token is immediately rejected by the auth guard. Requests using a revoked token get 401 Unauthorised.
Revoked keys stay in the table for 90 days (with a deleted_at timestamp) so the audit log still resolves the attribution for historical calls, then are hard-deleted by a scheduled job.
Rotation
Best practice for long-lived integrations:
- Create a new key with the same scopes.
- Update the consuming system to use the new token.
- Once you've confirmed the consumer is on the new key, revoke the old one.
There's no automated rotation in the UI today. If you need compliance-driven rotation (90-day cycles, etc.), wire a cron that does the above via the API — every endpoint used in the flow is itself callable with a token.
API surface
| Verb | Route | Purpose |
|---|---|---|
GET | /api/{tenant}/personal-access-tokens | List your own keys (metadata only — no plaintext) |
POST | /api/{tenant}/personal-access-tokens | Create a key. Response includes the plaintext once. |
DELETE | /api/{tenant}/personal-access-tokens/{id} | Revoke |
These endpoints are themselves callable with an API key, which means you can provision and rotate tokens programmatically.
Audit
Every API call carries the token's owner as causer_id, so actions taken via an integration are fully attributable in the Audit Log. The audit log also records token creations and revocations.
Permissions
- Any user — can create, list, and revoke their own keys.
- Admin — can see and revoke other users' keys via the Nova admin.
- The "Developer" sidebar section is gated on role
adminto keep the UI simple.
Related
- Audit Log — trace every API call back to the key owner.
- Roles & Permissions — the scopes you can grant to a key are a subset of your own permissions.
- Webhooks (planned) — the inverse direction: we call you instead of you calling us.