Maqsed

Maqsed API

One REST API for the customer app, the advertiser app and the control panel.

All systems operational Version 0.0.1 · bc9ff5b Base URL https://maqsed-api.dev-moltaqa.cloud Sandbox environment

API reference (Swagger)

Every endpoint with its request, responses and errors. Try requests right in the browser.

Open docs

Postman collection

Download and import. Sign-in requests save the token, so the rest are authenticated.

Download

OpenAPI 3 document

For code generators and API clients (Dart, Swift, Kotlin, TypeScript…).

Get JSON

Health

MySQL up 0.9 ms·Redis up 0.4 ms

View JSON

Request logs

Recent requests with their body, response, SQL and timing. Look up a failing call by its X-Request-Id.

Open logs

Background jobs

Queued and scheduled jobs (cleanups, notifications), with failures and retries.

Open board
This is a test environment.
  • SMS is simulated: no message is sent and every verification code is 1234.

Base paths

PathUsed bySigns in withToken
/v1/customerCustomer app (buyers and guests)Mobile number + SMS codemq_cus_…
/v1/advertiserAdvertiser app (individuals and establishments)Mobile number + SMS codemq_adv_…
/v1/adminControl panelMobile number + passwordmq_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

  1. New number? Send the registration form once; a code is sent by SMS:
    curl -X POST https://maqsed-api.dev-moltaqa.cloud/v1/customer/auth/register \
      -H 'Content-Type: application/json' \
      -d '{"name":"Sara","mobile":"0551234567","acceptTerms":true}'
    It answers a verificationId (and resendAfterSeconds; resend with register/resend-otp {"verificationId"}).
  2. 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"}'
  3. Next time, log in with login ({"mobile"}) then login/verify ({"verificationId","code"}). Call the API with the token:
    curl https://maqsed-api.dev-moltaqa.cloud/v1/customer/... \
      -H 'Authorization: Bearer mq_cus_…'
    Signed in, /account changes the language or the mobile (a code to the new number), DELETE /account deletes it, and POST auth/logout signs 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

Log in with mobile and password:
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.

  1. Sign in as usual (/v1/customer/auth/…) and keep the accessToken (mq_cus_…).
  2. Connect with a Socket.IO 4.x client to the namespace /customer on the API host, path /realtime, WebSocket only, with the token and the app’s language. Flutter (socket_io_client):
    final socket = IO.io('https://maqsed-api.dev-moltaqa.cloud/customer', IO.OptionBuilder()
        .setPath('/realtime')
        .setTransports(['websocket'])
        .setAuth({'token': accessToken, 'lang': 'ar'})
        .build());
    JavaScript: io('https://maqsed-api.dev-moltaqa.cloud/customer', { path: '/realtime', transports: ['websocket'], auth: { token, lang: 'ar' } }).
  3. If the connection is refused you get connect_error: read err.data.code. UNAUTHORIZED or ACCOUNT_DISABLED means the same as a 401: take the user to sign-in. err.data.message is already translated.
  4. 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.
  5. 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

EventPayloadWhat 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 }.

EventPayloadWhen
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).
  1. Sign in as usual (/v1/advertiser/auth/…) and keep the accessToken (mq_adv_…).
  2. Connect with a Socket.IO 4.x client to the namespace /advertiser on the API host, path /realtime, WebSocket only, with the token and the app’s language. Flutter (socket_io_client):
    final socket = IO.io('https://maqsed-api.dev-moltaqa.cloud/advertiser', IO.OptionBuilder()
        .setPath('/realtime')
        .setTransports(['websocket'])
        .setAuth({'token': accessToken, 'lang': 'ar'})
        .build());
    JavaScript: io('https://maqsed-api.dev-moltaqa.cloud/advertiser', { path: '/realtime', transports: ['websocket'], auth: { token, lang: 'ar' } }).
  3. If the connection is refused you get connect_error: read err.data.code. UNAUTHORIZED or ACCOUNT_DISABLED means the same as a 401: take the user to sign-in. err.data.message is already translated.
  4. 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.
  5. 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

EventPayloadWhat 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 }.

EventPayloadWhen
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).
  1. Log in as usual (POST /v1/admin/auth/login). The browser never gets a socket token: the admin’s accessToken stays on the dashboard’s server.
  2. 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": "…" }
  3. The page connects to the namespace /admin with the ticket, within 60 seconds. A ticket works once, so pass auth as 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() }),
    });
  4. If the connection is refused you get connect_error: read err.data.code. UNAUTHORIZED (an expired or used ticket, or the session ended) or ACCOUNT_DISABLED means the same as a 401: go to the login page. REALTIME_UNAVAILABLE (503) on the ticket request means try again shortly.
  5. 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

EventPayloadWhat 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
CodeStatusMessage
VALIDATION_FAILED400The request data is invalid
INVALID_JSON400The request body could not be read
UNAUTHORIZED401Please log in to complete this action.
FORBIDDEN403You don't have permission to do this
ACCOUNT_DISABLED403This user is disabled. Please contact the administration.
ROLE_DISABLED403Your role is disabled. Please contact the administration.
NOT_FOUND404The requested item was not found
INVALID_CREDENTIALS401The mobile number or password is incorrect. Please try again.
RESET_TOKEN_INVALID400This password reset has expired. Please request a new verification code.
ROLE_NAME_TAKEN409A role with this name already exists. Please enter another name.
ROLE_IN_USE409The role cannot be deleted because it is assigned to a System Administrator.
SYSTEM_ROLE_LOCKED409The Super Admin role can’t be changed.
SELF_CHANGE_NOT_ALLOWED403You can’t change your own role or account.
ROLE_NOT_AVAILABLE400This role is not available. Please choose another role.
SUPER_ADMIN_ROLE_RESERVED409The Super Admin role can’t be given to another administrator.
SUPER_ADMIN_PROTECTED403Only the Super Admin can change the Super Admin’s account.
ADVERTISER_HAS_DATA409The Service Provider cannot be deleted because related data exists. You can deactivate the account instead.
CATEGORY_IN_USE409This category is in use and can’t be deleted. You can deactivate it instead.
CATEGORY_TOO_DEEP400Options are the last level: they can’t have children.
CATEGORY_NAME_TAKEN409A category with this name already exists here.
CITY_EXISTS409A city with this name already exists.
CITY_IN_USE409This city is in use and can’t be deleted. You can deactivate it instead.
PACKAGE_IN_USE409This package has subscriptions and can’t be deleted. You can deactivate it instead.
FREE_PACKAGE_REQUIRED409This is the only free package for new advertisers. Confirm to continue without one.
FREE_PACKAGE_EXISTS409Another package is already the free package for these advertisers. Confirm to replace it; it will be deactivated.
REPORT_REASON_IN_USE409Reports were filed with this reason, so it can’t be deleted. You can deactivate it instead.
REPORT_REASON_NAME_TAKEN409A report reason with this name already exists.
BOOST_OPTION_EXISTS409A boost option with this duration already exists.
CONTACT_MESSAGE_REPLIED409This message has already been replied to.
PASSWORD_INCORRECT400The current password is incorrect.
PASSWORD_UNCHANGED400The new password must be different from the current one.
CONFLICT409The request conflicts with existing data
PAYLOAD_TOO_LARGE413The request is larger than allowed
TOO_MANY_REQUESTS429Too many requests, please try again shortly
FILE_REQUIRED400No file was attached.
FILE_TOO_LARGE413File size exceeds the allowed limit ({maxMb} MB).
FILE_TYPE_NOT_ALLOWED415Unsupported file type. Allowed: {allowed}
MOBILE_NOT_REGISTERED404No account is registered with this number. Please verify that the mobile number is correct.
MOBILE_ALREADY_REGISTERED409The mobile number already exists. Please verify the number.
MOBILE_UNCHANGED400The new number is the same as your current number.
EMAIL_ALREADY_REGISTERED409The email address is already registered.
CR_ALREADY_REGISTERED409The Commercial Registration number is already registered.
CITY_NOT_AVAILABLE400This city is not available. Please choose another.
CATEGORY_NOT_AVAILABLE400This category is not available. Please choose another category.
REPORT_REASON_NOT_AVAILABLE400This report reason is not available. Please choose another reason.
PACKAGE_NOT_AVAILABLE400This package is not available. Please choose another package.
NO_ACTIVE_SUBSCRIPTION403You have no active package. Please subscribe to a package to activate listings.
LISTING_ALLOWANCE_EXHAUSTED403All the active listings your package allows are in use. Pause one or upgrade your package.
LISTING_SUSPENDED_BY_ADMIN403This listing was suspended by the administration and can’t be changed.
LISTING_ACTION_NOT_ALLOWED409This action isn’t available for the listing’s current status.
LISTING_END_DATE_PASSED409This listing’s end date has passed. Edit the date to publish it again.
LISTING_UNAVAILABLE404This listing is no longer available.
ADVERTISER_UNAVAILABLE404This advertiser is no longer available.
ALREADY_REPORTED409You have already reported this listing.
CANNOT_REPORT_OWN_LISTING403You can’t report your own listing.
CHAT_DISABLED403Chat is currently unavailable.
CANNOT_CHAT_OWN_LISTING403You can’t start a chat on your own listing.
CANNOT_CHAT_WITH_YOURSELF403You can’t start a chat with yourself.
CONVERSATION_CLOSED409This chat is closed because the other account is no longer available.
BOOST_NOT_AVAILABLE409Boosting isn’t available for this listing right now.
FILE_NOT_AVAILABLE400This file can't be used. Please upload it again.
OTP_INVALID400The verification code is incorrect.
OTP_EXPIRED400The verification code is invalid or expired. Please request a new one.
OTP_TOO_MANY_ATTEMPTS429Too many incorrect attempts. Please request a new code.
VERIFICATION_INVALID400This verification is no longer valid. Please request a new code.
STATISTICS_RANGE_INVALID400Choose a valid date range (at most 366 days, 104 weeks or 36 months).
OTP_RESEND_TOO_SOON429You can request a new code in {seconds} seconds.
SMS_SEND_FAILED503The verification code could not be sent. Please try again.
REALTIME_UNAVAILABLE503Live updates are unavailable right now. Refresh to see changes
EXPORT_FAILED503The file couldn’t be created right now. Please try again.
INTERNAL_ERROR500Something went wrong, please try again