Authentication
How to authenticate your API requests with API keys.
API Keys
The eWasl API uses API keys to authenticate requests. Each key is scoped with specific permissions and can be revoked independently.
API keys follow the format ewasl_ followed by a random string. They are only shown once at creation time — store them securely.
Generating an API Key
- Log in to your eWasl account.
- Navigate to Settings > API Keys.
- Click Create New Key.
- Give your key a descriptive name (e.g., "Production App", "CI Pipeline", "MCP Integration").
- Select the permissions your key needs (
posts:read,posts:create). - Copy the generated key immediately — it will not be shown again.
You can also create keys programmatically via the Create Key endpoint.
Using the API Key
Include the API key in the Authorization header of every request using the Bearer scheme:
Example: List Posts
Example: Create a Post
Selecting a Workspace
Post endpoints default to the API credential owner's personal workspace. To act
inside a shared workspace, include its UUID in x-ewasl-workspace-id:
The header never grants access. eWasl verifies current membership, workspace
availability, role permissions, assigned brands, and the workspace owner's
entitlement on every request. A malformed identifier returns 400; revoked or
insufficient access returns 403. Never retry either response in another
workspace automatically.
Permissions
Each API key is scoped to specific permissions. Only the operations covered by the key's permissions will succeed.
| Permission | Description | Required For |
|---|---|---|
posts:read | Read post data | GET /api/v1/posts, GET /api/v1/connections |
posts:create | Create and publish posts | POST /api/v1/posts, POST /api/v1/posts/schedule |
If a key lacks the required permission, the API returns a 403 Forbidden error:
Error Responses
| HTTP Status | Error Code | Meaning |
|---|---|---|
| 401 | UNAUTHORIZED | No API key provided, or key is invalid/expired |
| 400 | WORKSPACE_SELECTION_INVALID | The explicit workspace UUID is malformed |
| 403 | FORBIDDEN | Key is valid but lacks the required permission |
| 403 | WORKSPACE_ACCESS_REVOKED | Membership or workspace access is no longer valid |
| 503 | WORKSPACE_UNAVAILABLE | Workspace authorization could not be verified safely |
| 429 | RATE_LIMITED | Too many requests — wait and retry |
401 Response Example
Security Best Practices
- Keep keys secret — Never commit API keys to source control or expose them in client-side JavaScript. Use environment variables.
- Use least privilege — Only grant the permissions your application actually needs.
- Rotate keys regularly — Revoke old keys and create new ones periodically, especially after team member changes.
- Use separate keys — Create different keys for different environments (development, staging, production) and different applications.
- Monitor usage — Check the
last_used_attimestamp on your keys in the dashboard to detect unauthorized use. - Revoke compromised keys — If a key is leaked, revoke it immediately via the dashboard or the Revoke Key endpoint.