Skip to main content

Merchant Service API

The Merchant Service manages business accounts, team members, and merchant configurations. It provides multi-merchant support, role-based team management, and centralized settings control.
Base URL: https://paymentgateway.redahaloubi.com/api/v1All endpoints require JWT authentication unless noted otherwise.

Authentication

All Merchant API endpoints require authentication via JWT Bearer token:
Permission Requirements:Most endpoints also require specific permissions based on your role in the merchant:
  • Read operations: All team members
  • Create operations: Owner, Admin, Manager
  • Update operations: Owner, Admin
  • Delete operations: Owner only

Rate Limits

Standard Endpoints

100 requests per second per userApplied to most merchant operations

Team Management

20 requests per second per merchantInvitation and team modification endpoints

Merchant Endpoints

Create Merchant

endpoint
/merchants
Create a new merchant account. Users can only create one merchant account. The user becomes the Owner with full access. Request Body
string
required
Public-facing business nameExample: “Acme Corporation”
Legal business name (if different from business name)Example: “Acme Corp LLC”
string
required
Business contact emailFormat: Valid email address
string
Business phone numberExample: “+1-555-123-4567”
string
Business website URLExample:https://acme.com
string
required
Type of business entityOptions: individual, sole_proprietor, partnership, corporation, non_profit
Example Request
Response (201 Created)
409 Conflict - User Already Has Merchant
400 Bad Request - Invalid Business Type
400 Bad Request - Invalid Email
Merchant Status:
  • pending_review: Newly created, awaiting verification
  • active: Verified and can process payments
  • suspended: Temporarily disabled
  • closed: Permanently deactivated

List User Merchants

endpoint
/merchants
Get all merchants where the authenticated user is a team member (including owned merchants). Example Request
Response (200 OK)
Multi-Merchant Support: Users can be members of multiple merchants with different roles. The response includes all merchants where the user has any level of access.

Get Merchant

endpoint
/merchants/:id
Get basic information about a specific merchant. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: read in the merchant Example Request
Response (200 OK)
403 Forbidden - Access Denied
404 Not Found

Get Merchant Details

endpoint
/merchants/:id/details
Get comprehensive merchant information including settings, business info, branding, and verification status. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: read in the merchant Example Request
Response (200 OK)

Update Merchant

endpoint
/merchants/:id
Update merchant information. Only specified fields will be updated. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: update (Owner or Admin) Request Body
string
Updated business name
string
Updated business emailFormat: Valid email address
string
Updated phone number
string
Updated website URL
Example Request
Response (200 OK)
403 Forbidden - Insufficient Permissions
400 Bad Request - Invalid Email

Delete Merchant

endpoint
/merchants/:id
Soft delete a merchant account. This action can only be performed by the Owner. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: delete (Owner only) Example Request
Response (200 OK)
Soft Delete: Merchants are soft-deleted, meaning:
  • Data is not permanently removed
  • Account can be restored by support
  • All team members lose access immediately
  • Active subscriptions/payments are cancelled
  • API keys are immediately deactivated
403 Forbidden - Only Owner Can Delete

Team Management Endpoints

Get Team Members

endpoint
/merchants/:id/team
List all team members in a merchant with their roles and status. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: read in the merchant Example Request
Response (200 OK)
Team Member Status:
  • active: User has accepted invitation and has access
  • pending: Invitation sent but not yet accepted
  • suspended: Access temporarily revoked

Invite Team Member

endpoint
/merchants/:id/team/invite
Send an invitation to join the merchant team. The invitee receives an email with an invitation token. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: create (Owner, Admin, or Manager) Request Body
string
required
Email address of the person to inviteFormat: Valid email address
string
required
Role ID to assign (from Auth Service roles)Format: UUID
string
required
Role name for displayOptions: Owner, Admin, Manager, Staff
Example Request
Response (201 Created)
400 Bad Request - User Already in Team
400 Bad Request - Pending Invitation Exists
403 Forbidden - Insufficient Permissions
Invitation Lifecycle:
  • Invitations expire after 7 days
  • User must have an account to accept (or register first)
  • One invitation per email per merchant at a time
  • Invitation token is single-use

Accept Invitation

endpoint
/invitations/:token/accept
Accept a team invitation using the invitation token received via email. Path Parameters
string
required
Invitation token from emailExample: inv_abc123def456ghi789jkl012
Example Request
Response (200 OK)
400 Bad Request - Invalid Token
400 Bad Request - Email Mismatch
409 Conflict - Already Accepted

Update Team Member Role

endpoint
/merchants/:id/team/:user_id
Change a team member’s role. Cannot modify the Owner’s role. Path Parameters
string
required
Merchant ID (UUID)
string
required
User ID of the team member to update (UUID)
Required Permission: update (Owner or Admin) Request Body
string
required
New role ID (UUID)
string
required
New role nameOptions: Admin, Manager, Staff
Example Request
Response (200 OK)
400 Bad Request - Cannot Modify Owner
403 Forbidden - Insufficient Permissions

Remove Team Member

endpoint
/merchants/:id/team/:user_id
Remove a team member from the merchant. Cannot remove the Owner. Path Parameters
string
required
Merchant ID (UUID)
string
required
User ID of the team member to remove (UUID)
Required Permission: delete (Owner only) Example Request
Response (200 OK)
400 Bad Request - Cannot Remove Owner
403 Forbidden - Only Owner Can Remove
Immediate Effect: Removing a team member immediately revokes all access to the merchant, including:
  • Dashboard access
  • API permissions
  • Payment data visibility
  • Reports and analytics

Get Pending Invitations

endpoint
/merchants/:id/invitations
List all pending (not yet accepted) invitations for a merchant. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: read in the merchant Example Request
Response (200 OK)

Cancel Invitation

endpoint
/invitations/:id
Cancel a pending invitation before it’s accepted. Path Parameters
string
required
Invitation ID (UUID)
Required Permission: delete (Owner) or invitation creator Example Request
Response (200 OK)
400 Bad Request - Already Accepted
403 Forbidden

Settings Endpoints

Get Settings

endpoint
/merchants/:id/settings
Get merchant settings including payment configuration, webhooks, and preferences. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: read in the merchant Example Request
Response (200 OK)

Update Settings

endpoint
/merchants/:id/settings
Update merchant settings. Only specified fields will be updated. Path Parameters
string
required
Merchant ID (UUID)
Required Permission: update (Owner or Admin) Request Body
string
Default currency for transactionsFormat: ISO 4217 currency code (3 letters)Example: “USD”, “EUR”, “MAD”
boolean
Enable automatic settlementDefault: true
string
Settlement frequencyOptions: daily, weekly, monthly
string
URL to receive webhook notificationsFormat: Valid HTTPS URL
string
Email for important notificationsFormat: Valid email address
boolean
Send email receipts to customersDefault: true
Example Request
Response (200 OK)
400 Bad Request - Invalid Currency
400 Bad Request - Invalid Webhook URL
400 Bad Request - Invalid Schedule
Webhook Configuration:When setting a webhook URL, the system will:
  1. Automatically generate a webhook secret (whsec_...)
  2. Send a test webhook to verify the endpoint
  3. Store the secret for HMAC signature verification
Include the webhook secret in your webhook handler to verify authenticity.

API Key Endpoints

API Key Management:These endpoints are in the Merchant Service but communicate with the Auth Service for actual key creation and storage. They require Owner permissions.

Create API Key

endpoint
/merchants/api-keys
Generate a new API key for payment processing. Requires Owner permissions. Request Body
string
required
Merchant ID for which to create the API key (UUID)
string
required
Descriptive name for the API keyExample: “Production Server”, “Staging Environment”
Example Request
Response (201 Created)
Save Your API Key:The plain_key is only shown once. Store it securely in environment variables or a secrets manager. You cannot retrieve it later.

List Merchant API Keys

endpoint
/merchants/api-keys/merchant/:merchant_id
List all API keys for a merchant (without revealing actual key values). Path Parameters
string
required
Merchant ID (UUID)
Required Permission: Owner Example Request
Response (200 OK)

Deactivate API Key

endpoint
/merchants/api-keys/:merchant_id/:id/deactivate
Deactivate an API key without deleting it. Deactivated keys cannot be used but remain visible. Path Parameters
string
required
Merchant ID (UUID)
string
required
API Key ID (UUID)
Required Permission: Owner Example Request
Response (200 OK)

Delete API Key

endpoint
/merchants/api-keys/:merchant_id/:id
Permanently delete an API key. This action cannot be undone. Path Parameters
string
required
Merchant ID (UUID)
string
required
API Key ID (UUID)
Required Permission: Owner Example Request
Response (200 OK)
Permanent Action:Deleted API keys cannot be recovered. Any services using this key will immediately stop working.

Permission Requirements Summary

Endpoints:
  • GET /merchants/:id
  • GET /merchants/:id/details
  • GET /merchants/:id/team
  • GET /merchants/:id/invitations
  • GET /merchants/:id/settings
Who Can Access: Owner, Admin, Manager, Staff
Endpoints:
  • POST /merchants/:id/team/invite
Who Can Access: Owner, Admin, ManagerRestrictions: Staff cannot invite team members
Endpoints:
  • PATCH /merchants/:id
  • PATCH /merchants/:id/settings
  • PATCH /merchants/:id/team/:user_id
Who Can Access: Owner, AdminRestrictions: Manager and Staff cannot modify merchant or settings
Endpoints:
  • DELETE /merchants/:id
  • DELETE /merchants/:id/team/:user_id
  • POST /merchants/api-keys (Create requires Owner)
  • All API key operations
Who Can Access: Owner onlyRestrictions: Even Admins cannot delete merchants or manage API keys

Common Workflows

Workflow 1: Setting Up a New Merchant

1

Create Merchant Account

User becomes Owner with full permissions
2

Configure Settings

Set currency, webhooks, and preferences
3

Generate API Key

Create key for payment processing
4

Invite Team Members

Add team members with appropriate roles

Workflow 2: Managing Team Members

1

Send Invitation

Invitee receives email with token
2

User Accepts Invitation

User joins merchant with assigned role
3

Update Role (if needed)

Change team member’s role
4

Remove Member (if needed)

Remove team member from merchant

Error Reference

Bad Request
Invalid request format or validation errorsCommon causes:
  • Invalid UUID format
  • Missing required fields
  • Invalid email format
  • Invalid business_type value
Unauthorized
Missing or invalid authentication tokenSolution: Include valid JWT token in Authorization header
Forbidden
Authenticated but lacks required permissionsCommon causes:
  • Insufficient role permissions
  • Not a member of the merchant
  • Trying to perform owner-only actions
Not Found
Requested resource doesn’t existCommon causes:
  • Invalid merchant ID
  • User not found
  • Invitation doesn’t exist
Conflict
Request conflicts with current stateCommon causes:
  • User already has a merchant
  • Email already invited
  • User already in team

Next Steps

Payment API

Process payments and manage transactions

Auth API

User authentication and authorization

Quick Start

Create your first payment intent

CLI Tool

Command-line interface for testing

Questions? Contact support at [email protected]