API reference (Swagger)
Every endpoint with its request, responses and errors. Try requests right in the browser.
Postman collection
Download and import. Sign-in requests save the token, so the rest are authenticated.
OpenAPI 3 document
For code generators and API clients (Dart, Swift, Kotlin, TypeScript…).
Health
MySQL up 0.9 ms·Redis up 0.4 ms
Request logs
Recent requests with their body, response, SQL and timing. Look up a failing call by its X-Request-Id.
Background jobs
Queued and scheduled jobs (cleanups, notifications), with failures and retries.
- SMS is simulated: no message is sent and every verification code is 1234.
Base paths
| Path | Used by | Signs in with | Token |
|---|---|---|---|
/v1/customer | Customer app (buyers and guests) | Mobile number + SMS code | mq_cus_… |
/v1/advertiser | Advertiser app (individuals and establishments) | Mobile number + SMS code | mq_adv_… |
/v1/admin | Control panel | Mobile number + password | mq_adm_… |
Send the token as Authorization: Bearer <token>. A token only works in its own app's path. Guests call public routes without one.
Sign in to the customer app
- New number? Send the registration form once; a code is sent by SMS:
It answers acurl -X POST https://maqsed-api.dev-moltaqa.cloud/v1/customer/auth/register \ -H 'Content-Type: application/json' \ -d '{"name":"Sara","mobile":"0551234567","acceptTerms":true}'verificationId(andresendAfterSeconds; resend withregister/resend-otp {"verificationId"}). - Send the id with the code to activate the account and get a token:
curl -X POST https://maqsed-api.dev-moltaqa.cloud/v1/customer/auth/register/verify \ -H 'Content-Type: application/json' \ -d '{"verificationId":"vrf_…","code":"1234"}' - Next time, log in with
login({"mobile"}) thenlogin/verify({"verificationId","code"}). Call the API with the token:
Signed in,curl https://maqsed-api.dev-moltaqa.cloud/v1/customer/... \ -H 'Authorization: Bearer mq_cus_…'/accountchanges the language or the mobile (a code to the new number),DELETE /accountdeletes it, andPOST auth/logoutsigns out.
Advertisers
Same steps under /v1/advertiser/auth, with one form per account type: register/individual (name, mobile, email, cityId from GET /v1/advertiser/cities) or register/establishment (adds the CR number, tax number and the CR document, uploaded first to register/files). Both are confirmed with register/verify. Login is login then login/verify. The response's nextStep says where the app goes. The More screens read GET settings (contact channels), GET content/pages/{about|terms|privacy|listing_policy} and POST contact/messages (Contact Us; guests too). Both apps browse GET categories, then categories/{id}/children, until hasChildren is false.
Control panel
curl -X POST https://maqsed-api.dev-moltaqa.cloud/v1/admin/auth/login \
-H 'Content-Type: application/json' \
-d '{"mobile":"0551234567","password":"…"}'Forgot it? auth/forgot-password sends a code by SMS, auth/forgot-password/verify (its verificationId and the code) returns a resetToken, and auth/reset-password sets the new one. GET auth/me returns the admin's role and permissions.Uploading files
Upload first with POST /v1/{app}/files?purpose=… (multipart, field file), then send the returned id in the endpoint's JSON body (e.g. imageIds, avatarFileId). Or send the whole form as multipart: its fields as text plus the files in named parts (images, avatar, icon…); the ids are filled in for you. The file type is read from its bytes; each purpose has its own types and size limit (see the docs).
Realtime events
Live updates (badges, notifications, chat) are pushed over Socket.IO. Each app has its own namespace and only receives its own account’s events.
- Sign in as usual (
/v1/customer/auth/…) and keep theaccessToken(mq_cus_…). - Connect with a Socket.IO 4.x client to the namespace
/customeron the API host, path/realtime, WebSocket only, with the token and the app’s language. Flutter (socket_io_client):
JavaScript:final socket = IO.io('https://maqsed-api.dev-moltaqa.cloud/customer', IO.OptionBuilder() .setPath('/realtime') .setTransports(['websocket']) .setAuth({'token': accessToken, 'lang': 'ar'}) .build());io('https://maqsed-api.dev-moltaqa.cloud/customer', { path: '/realtime', transports: ['websocket'], auth: { token, lang: 'ar' } }). - If the connection is refused you get
connect_error: readerr.data.code.UNAUTHORIZEDorACCOUNT_DISABLEDmeans the same as a401: take the user to sign-in.err.data.messageis already translated. - Listen to the events below. REST stays the source of truth: after every (re)connect, refetch what’s on screen, since events sent while offline aren’t replayed.
- On
session.ended(reason:logout,revoked,device_limit,subject_disabled,mobile_changed,account_deleted,password_reset,role_disabled(control panel),expired), stop using the token and go to sign-in. Disconnect the socket when the user logs out.
Events you receive
| Event | Payload | What to do |
|---|---|---|
session.ended | { reason } | Sent just before the server closes the socket because the session ended. Don’t reconnect: go to sign-in. |
notification.new | { id, type, group, title: { ar, en }, body: { ar, en }, target, createdAt } | A new notification: add it to the top of the list (pick the text in the app’s language). |
unread.counts | { notifications?, messages? } | Badge counts. Only the counts that changed are sent: notifications (the bell), messages (the Chats tab). |
message.new | { conversationId, message } | A chat message, to both sides (message.mine says whose). Same shape as the chat messages endpoint. |
conversation.updated | { conversationId, lastMessage, unreadCount, closed } | A chat list item changed (new message, read, or the chat closed): update that row. |
message.read | { conversationId, readAt } | The other side read the chat up to readAt: mark your messages up to then as read. |
Events you send
Send with an acknowledgement (socket.emitWithAck, or emitWithAck in Flutter); the answer is { ok: true } or { ok: false, code }.
| Event | Payload | When |
|---|---|---|
conversation.open | { conversationId } | When a chat opens on screen. Its new messages then don’t also arrive as push notifications. |
conversation.close | { conversationId } | When the user leaves the chat screen (or the app goes to the background). |
- Sign in as usual (
/v1/advertiser/auth/…) and keep theaccessToken(mq_adv_…). - Connect with a Socket.IO 4.x client to the namespace
/advertiseron the API host, path/realtime, WebSocket only, with the token and the app’s language. Flutter (socket_io_client):
JavaScript:final socket = IO.io('https://maqsed-api.dev-moltaqa.cloud/advertiser', IO.OptionBuilder() .setPath('/realtime') .setTransports(['websocket']) .setAuth({'token': accessToken, 'lang': 'ar'}) .build());io('https://maqsed-api.dev-moltaqa.cloud/advertiser', { path: '/realtime', transports: ['websocket'], auth: { token, lang: 'ar' } }). - If the connection is refused you get
connect_error: readerr.data.code.UNAUTHORIZEDorACCOUNT_DISABLEDmeans the same as a401: take the user to sign-in.err.data.messageis already translated. - Listen to the events below. REST stays the source of truth: after every (re)connect, refetch what’s on screen, since events sent while offline aren’t replayed.
- On
session.ended(reason:logout,revoked,device_limit,subject_disabled,mobile_changed,account_deleted,password_reset,role_disabled(control panel),expired), stop using the token and go to sign-in. Disconnect the socket when the user logs out.
Events you receive
| Event | Payload | What to do |
|---|---|---|
session.ended | { reason } | Sent just before the server closes the socket because the session ended. Don’t reconnect: go to sign-in. |
notification.new | { id, type, group, title: { ar, en }, body: { ar, en }, target, createdAt } | A new notification: add it to the top of the list (pick the text in the app’s language). |
unread.counts | { notifications?, messages? } | Badge counts. Only the counts that changed are sent: notifications (the bell), messages (the Chats tab). |
message.new | { conversationId, message } | A chat message, to both sides (message.mine says whose). Same shape as the chat messages endpoint. |
conversation.updated | { conversationId, lastMessage, unreadCount, closed } | A chat list item changed (new message, read, or the chat closed): update that row. |
message.read | { conversationId, readAt } | The other side read the chat up to readAt: mark your messages up to then as read. |
Events you send
Send with an acknowledgement (socket.emitWithAck, or emitWithAck in Flutter); the answer is { ok: true } or { ok: false, code }.
| Event | Payload | When |
|---|---|---|
conversation.open | { conversationId } | When a chat opens on screen. Its new messages then don’t also arrive as push notifications. |
conversation.close | { conversationId } | When the user leaves the chat screen (or the app goes to the background). |
- Log in as usual (
POST /v1/admin/auth/login). The browser never gets a socket token: the admin’saccessTokenstays on the dashboard’s server. - The dashboard’s server asks for a one-time ticket with the admin’s token and hands only the ticket to the page:
curl -X POST https://maqsed-api.dev-moltaqa.cloud/v1/admin/realtime/ticket \ -H 'Authorization: Bearer mq_adm_…' # → { "ticket": "…", "expiresAt": "…" } - The page connects to the namespace
/adminwith the ticket, within 60 seconds. A ticket works once, so passauthas a function: every reconnect then gets a fresh ticket.const socket = io('https://maqsed-api.dev-moltaqa.cloud/admin', { path: '/realtime', transports: ['websocket'], auth: async (cb) => cb({ ticket: await getTicketFromYourServer() }), }); - If the connection is refused you get
connect_error: readerr.data.code.UNAUTHORIZED(an expired or used ticket, or the session ended) orACCOUNT_DISABLEDmeans the same as a401: go to the login page.REALTIME_UNAVAILABLE(503) on the ticket request means try again shortly. - Listen to the events below, and refetch what’s on screen after every (re)connect. On
session.ended(reason:logout,revoked,device_limit,subject_disabled,mobile_changed,account_deleted,password_reset,role_disabled(control panel),expired), go to the login page.
Events you receive
| Event | Payload | What to do |
|---|---|---|
session.ended | { reason } | Sent just before the server closes the socket because the session ended. Don’t reconnect: go to sign-in. |
permissions.changed | {} | The admin’s role changed (permissions edited, role deactivated). Refetch GET /v1/admin/auth/me and show “Changes have been made to the permissions granted to you.” With no permissions left, show the no-access screen. |
notification.new | { id, type, group, title: { ar, en }, body: { ar, en }, target, createdAt } | A new notification: add it to the top of the list (pick the text in the app’s language). |
unread.counts | { notifications } | The header bell’s unread count. |
The dashboard sends no events.
Conventions
Language
Send Accept-Language: ar or en (or ?lang=). Arabic is the default; a signed-in account's saved language is used when the request names none.
Errors
Always { code, message, details?, requestId }. Branch on code; show message. details lists field problems with their own message.
Request IDs
Every response has an X-Request-Id header. Include it when reporting a problem.
Mobile numbers
Saudi numbers as typed (05…, 5…, +9665…, Arabic digits too); responses use +9665….
Dates
Times are ISO 8601 in UTC, for example 2026-10-07T09:30:00.000Z.
Lists
App lists scroll with { items, nextCursor }; control panel tables page with { items, page, limit, total }.
Error codes
All 71 codes with their HTTP status and English message
| Code | Status | Message |
|---|---|---|
VALIDATION_FAILED | 400 | The request data is invalid |
INVALID_JSON | 400 | The request body could not be read |
UNAUTHORIZED | 401 | Please log in to complete this action. |
FORBIDDEN | 403 | You don't have permission to do this |
ACCOUNT_DISABLED | 403 | This user is disabled. Please contact the administration. |
ROLE_DISABLED | 403 | Your role is disabled. Please contact the administration. |
NOT_FOUND | 404 | The requested item was not found |
INVALID_CREDENTIALS | 401 | The mobile number or password is incorrect. Please try again. |
RESET_TOKEN_INVALID | 400 | This password reset has expired. Please request a new verification code. |
ROLE_NAME_TAKEN | 409 | A role with this name already exists. Please enter another name. |
ROLE_IN_USE | 409 | The role cannot be deleted because it is assigned to a System Administrator. |
SYSTEM_ROLE_LOCKED | 409 | The Super Admin role can’t be changed. |
SELF_CHANGE_NOT_ALLOWED | 403 | You can’t change your own role or account. |
ROLE_NOT_AVAILABLE | 400 | This role is not available. Please choose another role. |
SUPER_ADMIN_ROLE_RESERVED | 409 | The Super Admin role can’t be given to another administrator. |
SUPER_ADMIN_PROTECTED | 403 | Only the Super Admin can change the Super Admin’s account. |
ADVERTISER_HAS_DATA | 409 | The Service Provider cannot be deleted because related data exists. You can deactivate the account instead. |
CATEGORY_IN_USE | 409 | This category is in use and can’t be deleted. You can deactivate it instead. |
CATEGORY_TOO_DEEP | 400 | Options are the last level: they can’t have children. |
CATEGORY_NAME_TAKEN | 409 | A category with this name already exists here. |
CITY_EXISTS | 409 | A city with this name already exists. |
CITY_IN_USE | 409 | This city is in use and can’t be deleted. You can deactivate it instead. |
PACKAGE_IN_USE | 409 | This package has subscriptions and can’t be deleted. You can deactivate it instead. |
FREE_PACKAGE_REQUIRED | 409 | This is the only free package for new advertisers. Confirm to continue without one. |
FREE_PACKAGE_EXISTS | 409 | Another package is already the free package for these advertisers. Confirm to replace it; it will be deactivated. |
REPORT_REASON_IN_USE | 409 | Reports were filed with this reason, so it can’t be deleted. You can deactivate it instead. |
REPORT_REASON_NAME_TAKEN | 409 | A report reason with this name already exists. |
BOOST_OPTION_EXISTS | 409 | A boost option with this duration already exists. |
CONTACT_MESSAGE_REPLIED | 409 | This message has already been replied to. |
PASSWORD_INCORRECT | 400 | The current password is incorrect. |
PASSWORD_UNCHANGED | 400 | The new password must be different from the current one. |
CONFLICT | 409 | The request conflicts with existing data |
PAYLOAD_TOO_LARGE | 413 | The request is larger than allowed |
TOO_MANY_REQUESTS | 429 | Too many requests, please try again shortly |
FILE_REQUIRED | 400 | No file was attached. |
FILE_TOO_LARGE | 413 | File size exceeds the allowed limit ({maxMb} MB). |
FILE_TYPE_NOT_ALLOWED | 415 | Unsupported file type. Allowed: {allowed} |
MOBILE_NOT_REGISTERED | 404 | No account is registered with this number. Please verify that the mobile number is correct. |
MOBILE_ALREADY_REGISTERED | 409 | The mobile number already exists. Please verify the number. |
MOBILE_UNCHANGED | 400 | The new number is the same as your current number. |
EMAIL_ALREADY_REGISTERED | 409 | The email address is already registered. |
CR_ALREADY_REGISTERED | 409 | The Commercial Registration number is already registered. |
CITY_NOT_AVAILABLE | 400 | This city is not available. Please choose another. |
CATEGORY_NOT_AVAILABLE | 400 | This category is not available. Please choose another category. |
REPORT_REASON_NOT_AVAILABLE | 400 | This report reason is not available. Please choose another reason. |
PACKAGE_NOT_AVAILABLE | 400 | This package is not available. Please choose another package. |
NO_ACTIVE_SUBSCRIPTION | 403 | You have no active package. Please subscribe to a package to activate listings. |
LISTING_ALLOWANCE_EXHAUSTED | 403 | All the active listings your package allows are in use. Pause one or upgrade your package. |
LISTING_SUSPENDED_BY_ADMIN | 403 | This listing was suspended by the administration and can’t be changed. |
LISTING_ACTION_NOT_ALLOWED | 409 | This action isn’t available for the listing’s current status. |
LISTING_END_DATE_PASSED | 409 | This listing’s end date has passed. Edit the date to publish it again. |
LISTING_UNAVAILABLE | 404 | This listing is no longer available. |
ADVERTISER_UNAVAILABLE | 404 | This advertiser is no longer available. |
ALREADY_REPORTED | 409 | You have already reported this listing. |
CANNOT_REPORT_OWN_LISTING | 403 | You can’t report your own listing. |
CHAT_DISABLED | 403 | Chat is currently unavailable. |
CANNOT_CHAT_OWN_LISTING | 403 | You can’t start a chat on your own listing. |
CANNOT_CHAT_WITH_YOURSELF | 403 | You can’t start a chat with yourself. |
CONVERSATION_CLOSED | 409 | This chat is closed because the other account is no longer available. |
BOOST_NOT_AVAILABLE | 409 | Boosting isn’t available for this listing right now. |
FILE_NOT_AVAILABLE | 400 | This file can't be used. Please upload it again. |
OTP_INVALID | 400 | The verification code is incorrect. |
OTP_EXPIRED | 400 | The verification code is invalid or expired. Please request a new one. |
OTP_TOO_MANY_ATTEMPTS | 429 | Too many incorrect attempts. Please request a new code. |
VERIFICATION_INVALID | 400 | This verification is no longer valid. Please request a new code. |
STATISTICS_RANGE_INVALID | 400 | Choose a valid date range (at most 366 days, 104 weeks or 36 months). |
OTP_RESEND_TOO_SOON | 429 | You can request a new code in {seconds} seconds. |
SMS_SEND_FAILED | 503 | The verification code could not be sent. Please try again. |
REALTIME_UNAVAILABLE | 503 | Live updates are unavailable right now. Refresh to see changes |
EXPORT_FAILED | 503 | The file couldn’t be created right now. Please try again. |
INTERNAL_ERROR | 500 | Something went wrong, please try again |