API Authentication
How to authenticate with the FileRelay API using personal access tokens, roles, and scopes.
API Authentication
All FileRelay API requests authenticate with a personal access token sent as a Bearer [REDACTED] Tokens are issued to your user account and inherit your live workspace role on every request. The addressed workspace comes from the URL, not the token.
curl -X GET https://filerelay.dev/api/acme/production/documents \
-H "Authorization: Bearer [REDACTED]"
Requests without a valid token receive 401 Unauthorized:
{
"error": {
"code": "unauthorized",
"message": "Missing or invalid API key."
}
}
Creating a Token
Mint tokens from your user settings in the dashboard. A token acts as you: it can address every workspace you're a member of, with exactly your role there. If your role on a workspace changes, the token's access changes immediately — no reissue needed.
Addressing a Workspace
Every workspace-scoped endpoint includes the target workspace in its URL:
https://filerelay.dev/api/{workspaceSlug}/<resource>
{workspaceSlug} is the workspace's slug, visible in the dashboard URL bar. The calling user comes from the token alone — no user slug is needed because each deployment serves one client.
- One token addresses every workspace you're a member of — just change the path.
- Calling a workspace you're not a member of returns
404 Not Found. We never confirm a workspace exists to non-members. - All reads are pinned to the URL workspace. Your dashboard's currently-open workspace is irrelevant to API calls.
Discovering Workspaces
curl -X GET https://filerelay.dev/api/me/workspaces \
-H "Authorization: Bearer [REDACTED]"
Role-Based Permissions
| Action | Owner | Admin | Member |
|---|---|---|---|
| Read repos, destinations, connections, documents, certs, requests, audit log | ✓ | ✓ | ✓ |
| Retry a document | ✓ | ✓ | ✓ |
| Invoke RFC / BAPI calls | ✓ | ✓ | |
| Create / update / delete repos, destinations, connections | ✓ | ✓ | |
| Activate / deactivate / delete certificates, export PEM | ✓ | ✓ | |
| Replay captured requests | ✓ | ✓ | |
| Export the audit log | ✓ | ✓ | ✓ |
Exceeding your role returns 403 Forbidden with code: "forbidden".
Token Scopes (Least Privilege)
Tokens minted without abilities inherit your full role. Tokens minted with abilities are restricted to the intersection of role and scopes — scopes can only narrow, never widen.
| Ability | Effect |
|---|---|
workspace:<id> |
Pin the token to one workspace ID; every other workspace path returns 403 |
scope:<ability> |
Allow only that API ability, e.g. scope:documents:read, scope:destinations:write |
Abilities mirror the endpoint names: repositories:read|write, destinations:read|write|test, connections:read|write, documents:read|write, certificates:read|write, requests:read|replay, rfc:read|invoke, members:read|write. A token with only scope:documents:read can list documents but cannot retry one, and cannot read anything else.
Example: a read-only monitoring token for one workspace — mint with workspace:<id> + scope:documents:read.
Security Best Practices
- Never commit tokens to version control. Use environment variables or a secrets manager.
- Mint least-privilege tokens. A Member-role account plus narrow scopes is the safest integration identity.
- Rotate periodically. Create a replacement, update your systems, then delete the old token.
- Scope tokens to one workspace with
workspace:<id>whenever the integration only needs one.
Troubleshooting
401 Unauthorized
- The
Authorizationheader is missing, malformed, or the token was deleted.
403 Forbidden
- Valid token, but the role is too low for the action — or the token's scopes don't include the endpoint's ability. The error names the missing scope.
404 Not Found
- The
{workspaceSlug}doesn't resolve, you're not a member, or the resource ID belongs to another workspace. UseGET /api/me/workspacesfor canonical paths.
Next Steps
- API Overview -- Base URL, response format, and rate limits
- Documents API -- Query and manage documents
- Repositories API -- Manage sources programmatically