Wocart
Wocart API

Users

Server

List users

GET
https://api.wocart.store
/api/users
X-API-Key (header)

Returns a paginated list of team members. Each user includes their scopes array (["*"] for admins).

List users › query Parameters

role
​string · enum
Enum values:
admin
staff
status
​string · enum
Enum values:
active
inactive
search
​string

Search by name or email

Search by name or email

limit
​integer · max: 100
Default: 50
offset
​integer | null · min: 0
Default: 0

List users › Responses

200

List of users

success
​boolean · required
​User[] · required
count
​integer · required

Number of items returned


Create user

POST
https://api.wocart.store
/api/users
X-API-Key (header)

Creates a new team member. Admin only.

What happens:

  1. A user account is created in the database with a secure temporary password
  2. The password is hashed using scrypt (same algorithm as better-auth)
  3. An API key is generated for programmatic access
  4. Initial permission scopes are assigned (if role is staff)
  5. A best-effort invite email is sent via Sendili when the store's email config exists and is enabled — the outcome is reported in emailSent/emailError, and creation never fails because of the email

Authentication:

  • The new user receives a temporary password (returned once in this response, and included in the invite email when it sends)
  • They can sign in using email + temporary password
  • They should change their password on first login for security

Note: scopes are ignored for admin users — admins always have ["*"]. The API key is never emailed.

Create user › Request Body

email
​string · email · required
name
​string · minLength: 1 · required
role
​string · enum

Defaults to staff.

Enum values:
admin
staff
Default: staff
scopes
​string[]

Initial permission scopes. Ignored if role is admin.

Default: []
language
​string · enum

Language for the invite email. Defaults to en.

Enum values:
ar
en

Create user › Responses

User created. The apiKey and tempPassword fields are returned only in this response — store them immediately.

success
​boolean · required
​User · required

Team member record with permission scopes

apiKey
​string · required

The raw API key for the new user — returned once at creation. Use POST /{id}/api-key/rotate to issue a new key.

tempPassword
​string · required

Temporary password for the new user — returned once at creation. Share this with the user securely. They should change it on first login.

emailSent
​boolean · required

Whether the invite email was handed to Sendili. False when email sending is not configured or the send failed — check emailError.

emailError
​string | null · required

Stable failure code when the invite email could not be sent: out_of_credits | invalid_key | forbidden | rate_limited | validation | transient. Null when sent or simply not configured.

message
​string · required

Get user

GET
https://api.wocart.store
/api/users/{id}
X-API-Key (header)

Returns full user record including their scopes array.

Get user › path Parameters

id
​string · required

User ID

User ID

Get user › Responses

200

User detail with scopes

success
​boolean · required
​User · required

Team member record with permission scopes


Update user

PATCH
https://api.wocart.store
/api/users/{id}
X-API-Key (header)

Partial update — only include fields you want to change. To change scopes, use POST /{id}/scopes and DELETE /{id}/scopes/{scope}. To change role only, prefer PATCH /{id}/role.

Update user › path Parameters

id
​string · required

User ID

User ID

Update user › Request Body

email
​string · email
name
​string · minLength: 1
role
​string · enum
Enum values:
admin
staff
status
​string · enum
Enum values:
active
inactive

Update user › Responses

200

User updated

success
​boolean · required
​User · required

Team member record with permission scopes

message
​string · required

Update user role

PATCH
https://api.wocart.store
/api/users/{id}/role
X-API-Key (header)

Dedicated endpoint for role-only changes. Changing to admin effectively grants ["*"] scope.

Update user role › path Parameters

id
​string · required

User ID

User ID

Update user role › Request Body

role
​string · enum · required
Enum values:
admin
staff

Update user role › Responses

200

Role updated

success
​boolean · required
​User · required

Team member record with permission scopes

message
​string · required

Grant scope to user

POST
https://api.wocart.store
/api/users/{id}/scopes
X-API-Key (header)

Grants a single permission scope to the user. Returns the full updated user record.

Grant scope to user › path Parameters

id
​string · required

User ID

User ID

Grant scope to user › Request Body

scope
​string · minLength: 1 · required

Grant scope to user › Responses

Scope granted

success
​boolean · required
​User · required

Team member record with permission scopes

message
​string · required

Revoke scope from user

DELETE
https://api.wocart.store
/api/users/{id}/scopes/{scope}
X-API-Key (header)

Removes a permission scope from the user. If the scope was not granted, the operation succeeds silently.

Revoke scope from user › path Parameters

id
​string · required

User ID

User ID

scope
​string · required

The scope to revoke

The scope to revoke

Revoke scope from user › Responses

200

Scope revoked. Returns full updated user record.

success
​boolean · required
​User · required

Team member record with permission scopes

message
​string · required

Rotate API key

POST
https://api.wocart.store
/api/users/{id}/api-key/rotate
X-API-Key (header)

Generates a new API key for the user, invalidating the previous one. Admin only. The raw key is returned only once — store it securely.

Rotate API key › path Parameters

id
​string · required

User ID

User ID

Rotate API key › Responses

200

New API key issued. The raw key is shown only in this response.

success
​boolean · required
​object · required
message
​string · required