# Stream App API Documentation > Complete API documentation and guides for Stream App ## Quick Start for LLMs > Read this section first. It is written for AI agents and coding assistants integrating with Stream (streampay.sa), a Saudi payment platform for payment links, invoices, subscriptions, installments, coupons, and a hosted customer billing portal. Everything below is derived from the guides and API reference listed in the Table of Contents further down. ### Mental model (read before writing any code) - **Default flow:** Your server -> `POST /api/v2/payment_links` -> redirect the customer (or embed) to the returned `url` -> Stream hosted checkout -> customer lands on your `success_redirect_url` / `failure_redirect_url` -> **you verify server-side** and/or receive webhooks. - **Payment links are the recommended way to collect money.** The invoice and subscription create endpoints say so themselves: "For most use cases, use the Checkout/Payment Link API instead." Do not default to `POST /invoices` or `POST /subscriptions`. - **Entities are created only after a successful payment.** A paid link creates: - one-time products -> an **invoice** + **payment(s)** - recurring products -> a **subscription** + initial **invoice** + **payment** - A failed attempt creates nothing (no invoice, payment, or subscription). - **Recurrence lives on the product, not the link.** Create the product as one-time or recurring first, then reference it by `product_id`. - **"Consumer" = "customer".** The API says consumer; the dashboard says customer. The consumer `id` is what you pass as `organization_consumer_id`. ### Base URL and authentication - Base URL: `https://stream-app-service.streampay.sa/api/v2` - Header on every request: `x-api-key: ` - Build the token: `echo -n 'api-key:api-secret' | base64` - Create the key pair in the dashboard under Settings -> API Keys. The secret is shown at creation; store it like a password. - Never put the key pair or token in browser/mobile code. All calls go through your backend. - Optional header `x-branch-id: ` selects the branch. If omitted, the key's default branch is used. Keys only reach branches they were granted (or all branches if created with `is_all_branches`). Unauthorized branch -> 4xx. - The MCP server uses a different header: `Authorization: Bearer ` (see MCP section). ### The five-step integration **1. (Optional) Create a consumer** - `POST /api/v2/consumers` Only `name` is required. Recommended: `phone_number` (E.164, e.g. `+966501234567`) or `email` so Stream can notify them, plus `external_id` for your own ID. ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/consumers \ -H "x-api-key: $STREAM_TOKEN" -H "Content-Type: application/json" \ -d '{"name":"Ahmad Ali","email":"ahmad@example.com","phone_number":"+966501234567","external_id":"cust_12345"}' ``` Returns the consumer; keep `id`. Duplicate phone/email -> `DUPLICATE_CONSUMER`: list consumers and reuse the existing `id`. **2. Have a product** - `POST /api/v2/products` (one-time or recurring). Keep its `id`. A product can hold one active price per currency (`POST /products/{product_id}/prices` adds another currency). **3. Create the payment link** - `POST /api/v2/payment_links` ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/payment_links \ -H "x-api-key: $STREAM_TOKEN" -H "Content-Type: application/json" \ -d '{ "name": "Order 789", "items": [{"product_id": "PRODUCT_UUID", "quantity": 1}], "contact_information_type": "PHONE", "currency": "SAR", "max_number_of_payments": 1, "organization_consumer_id": "CONSUMER_UUID", "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure", "custom_metadata": {"order_id": "789"} }' ``` - Response includes `url`, `id`, `status` (e.g. `ACTIVE`), `amount` (decimal string like `"2500.00"`), `currency`. Redirect the customer to `url`. - Omit `organization_consumer_id` for a shareable link: each payer enters their own details and a consumer is auto-created. Use a higher `max_number_of_payments` for these (docs example: 100). - Set `organization_consumer_id` + `max_number_of_payments: 1` for a link tied to one known customer; the checkout skips the details form. **4. Handle the redirect, then verify.** Stream appends query params (`status`, `message`, `payment_link_id`, and on success `invoice_id`, `payment_id`, `consent_id`, `organization_consumer_id`). **Do not trust them.** Fetch `GET /api/v2/invoices/{invoice_id}` and check `status`, `amount`, `currency` against your own order before fulfilling. **5. Confirm asynchronously with webhooks** (recommended) and/or poll `GET /api/v2/payments/{id}` and `GET /api/v2/subscriptions/{id}`. The `status` field on the fetched object is the source of truth. ### Embedded checkout (instead of redirect) Create the payment link on your server, pass only the `url` to the page: ```html
``` Optional: `minHeightPx` (280), `maxHeightPx` (920), `vhCapPx` (800), `vhFraction` (0.7). Apple Pay in embedded mode is registered from Settings → Company profile → Apple Pay domains: download the verification file there, host it unchanged at `https:///.well-known/apple-developer-merchantid-domain-association` (exact file name, HTTPS, no redirect), then verify the domain. `example.com` and `www.example.com` are separate. ### Webhooks in 60 seconds - Register endpoints in the dashboard (Settings -> Webhooks) and pick event types. There is also a `POST /api/v2/webhooks` endpoint. - Body shape: `event_type`, `entity_type`, `entity_id`, `entity_url`, `status`, `data`, `timestamp`. `data.metadata` echoes your `custom_metadata`. - Headers: `X-Webhook-Event`, `X-Webhook-Entity-Type`, `X-Webhook-Entity-ID`, `X-Webhook-Timestamp`, `X-Webhook-Signature` (`t={timestamp},v1={signature}`). - **Verify the signature:** HMAC-SHA256 over the exact string `"{timestamp}.{raw_request_body}"` using the webhook's `secret_key`, hex digest, constant-time compare to `v1`. Use the **raw bytes** of the body, not re-serialized JSON. ```python import hmac, hashlib def verify(secret: str, raw_body: bytes, header: str) -> bool: parts = dict(p.split("=", 1) for p in header.split(",")) msg = f"{parts['t']}.{raw_body.decode()}" expected = hmac.new(secret.encode(), msg.encode(), hashlib.sha256).hexdigest() return hmac.compare_digest(expected, parts["v1"]) ``` - Respond with any 2xx quickly. Non-2xx triggers up to 5 retries at roughly 5 min, 30 min, 2 h, 6 h, 12 h; after that the delivery is marked failed. ### Testing - Use the sandbox environment with Moyasar test cards. Name: any two words. Expiry: any future date. CVC: any 3 digits (4 for AMEX). - Success: Mada `4201320111111010`, Visa `4111111111111111`, Mastercard `5421080101000000`, AMEX `340000000900000`. - Insufficient funds: Mada `4201320000311101`, Visa `4123120001090000`, Mastercard `5457210001000092`, AMEX `340033000000000`. - Generic decline: Mada `4201321234411220`, Visa `4123120001090109`. - 3DS failure cases exist for Visa only (see Testing Cards guide). - **Apple Pay in sandbox is driven by amount:** 200.00-300.00 SAR succeeds; 1000.00-1700.00 SAR hits assorted failures; **any other amount fails.** Do not use random amounts when testing Apple Pay. --- ## Tips and Tricks for LLMs ### Hard rules (violating these causes real bugs or lost money) 1. **Never mix one-time and recurring products in one payment link.** Split into two links tied to one internal order (store a shared order reference in `custom_metadata` or your DB), run them sequentially, and mark the order complete only after both succeed. 2. **Never fulfill an order from redirect query params alone.** Verify via `GET /invoices/{invoice_id}` (status, amount, currency) or a verified webhook. 3. **Never expose the key pair, the Base64 token, or a webhook `secret_key` client-side.** Embedded checkout only needs the link `url`. 4. **Always verify `X-Webhook-Signature`** and reject missing or invalid ones. 5. **Make webhook handlers idempotent.** Retries and multi-event flows mean you will see duplicates and out-of-order delivery. Key on `entity_id` + `event_type`. 6. **Do not use the redirect `id` param as a Stream ID.** It is the payment gateway's ID, for support debugging only. Use `payment_id` or `invoice_id`. ### Choosing the right endpoint | Goal | Use | |---|---| | Collect a one-off payment | `POST /payment_links` with one-time product(s) | | Start a subscription | `POST /payment_links` with recurring product(s) | | Take payment via your own page | `POST /payment_links` + Embedded Checkout | | Record money received offline (cash, bank transfer, etc.) | Create invoice, then `POST /payments/{id}/mark-paid` | | Send customer to self-service billing | `POST /consumer_portal/sessions` | | Charge a saved card on demand | `POST /payments/auto-charge-on-demand/{payment_id}` (restricted; only some orgs) | | Pause billing | `POST /subscriptions/{id}/freeze` | | Reverse a payment | `POST /payments/{id}/refund` | ### Consumers - Check for an existing consumer before creating one (match by `external_id`, or `GET /consumers?search_term=...`) to avoid `DUPLICATE_CONSUMER`. - Phone numbers must be E.164. `+966501234567`, not `0501234567`. - `communication_methods` accepts `WHATSAPP`, `EMAIL`, `SMS`. Provide at least a phone or email, otherwise Stream cannot notify the customer. - `DELETE` on a consumer is a soft delete (`is_deleted`). ### Payment links - `contact_information_type` is `PHONE` or `EMAIL` (shown in docs examples) and controls which contact the checkout collects/uses for login. - Put your own references in `custom_metadata` (arbitrary JSON, nested allowed). It comes back in webhook `data.metadata`, which is the cleanest way to join Stream events to your orders. - `language=en` or `language=ar` as a query param on the link URL switches the checkout UI language only. Default is Arabic (or the org's configured language). - Installments: pass `payment_methods: {"installment": true|false}` on the link to override the org default. Omit `payment_methods` to inherit the org setting. - Link coupons and status are managed after creation with `PATCH`-style endpoints: Update Payment Link Coupons, Update Payment Link Status. To retire a link, update its status rather than deleting. - Failed payment-link attempts produce **no** invoice/payment/subscription. To catch these, subscribe to `PAYMENT_LINK_PAY_ATTEMPT_FAILED`, not `PAYMENT_FAILED`. - Redirect `status` values: `paid`, `pending`, `failed`, `failed_internal_error`. `failed` = definite decline, let the payer retry. `failed_internal_error` = unclear (timeout etc.); money may or may not have moved, so tell the payer to contact support and reconcile via the API before retrying or refunding. ### Installments - Customers choose 2, 3, or 4 installments at checkout. **Installments are disabled automatically for recurring products.** - Each installment is its own payment with its own due date. Default split period is monthly; it cannot be changed via API or dashboard (contact support). - Minimum is **100 SAR per installment**. A 250 SAR order allows 2 installments but not 3. This minimum is also support-only to change. - Rounding remainder goes to the **last** installment (999.98 / 3 -> 333.33, 333.33, 333.32). - Webhooks: one `PAYMENT_SUCCEEDED` per installment paid; `INVOICE_COMPLETED` only fires once **every** installment is paid. - Invoice-level installment settings are configured in the dashboard (invoices are created from the UI per the guide); payment-link defaults live in Settings -> Payment Settings. ### Subscriptions - Cancel (`POST /subscriptions/{id}/cancel`): an `ACTIVE` subscription is **scheduled to cancel at period end** and stays active until then. `INACTIVE`, `TRIALING`, and `TRIAL_PENDING` subscriptions cancel **immediately**. Pass `cancel_related_invoices` to also cancel ongoing invoices. Undo a pending cancellation with the Uncancel endpoint. - Update (`PUT /subscriptions/{id}`): - Items, subscription-level coupons, and recurring interval changes are **deferred to `current_period_end`** as a "pending change". The response includes `pending_change` with `next_invoice_preview` and a per-line diff. - If the next-cycle invoice already exists and is unpaid, it is cancelled and reissued at the new amount. - Description, auto-cancel cycle count (`until cycle number`), and payment-method overrides apply **immediately**. - You cannot change the payer. Cancel and create a new subscription instead. - Revert a scheduled change with `DELETE /subscriptions/{id}/pending-change` (returns 200 even if nothing was scheduled). - Freeze pauses **invoice generation** for a date range and auto-resumes afterward. Freezes have their own list / update / delete endpoints. - Renewal webhook sequence: `INVOICE_CREATED` -> `PAYMENT_SUCCEEDED` -> `INVOICE_COMPLETED` (plus `SUBSCRIPTION_CYCLE_RENEWED_SUCCESSFULLY`). On `INVOICE_COMPLETED`, check `subscription_id` in the payload to recognize a renewal. Failed automatic renewals emit `SUBSCRIPTION_CYCLE_RENEWAL_FAILED`. - Plan-change event family: `SUBSCRIPTION_PLAN_CHANGE_SCHEDULED` (deferred), `..._CHANGED` (deferred change applied), `..._CHANGE_CANCELED`, `..._CHANGE_INVOICE_REISSUED`, and `SUBSCRIPTION_PLAN_UPDATED` (immediate change such as seats, add-ons, cycle count). ### Payments, refunds, and manual payments - Multiple refunds per payment are supported. Partial refund -> payment status `PARTIALLY_REFUNDED` + `PAYMENT_PARTIALLY_REFUNDED`. Cumulative total reaches the payment amount -> `REFUNDED` + `PAYMENT_REFUNDED`. **The invoice status does not change on refund.** Subscribe to both refund events if you handle partials. - Webhook refund payloads carry `amount_refunded` (this refund) and `total_amount_refunded` (cumulative). - If a payment belongs to a shared charge, set `payment_is_part_of_related_set: true` on the refund request to spread the refund across the related payments in invoice order. - Refund errors: `PAYMENT_REFUNDED_ALREADY` (duplicate, safe to treat as done), `PAYMENT_REFUNDED_FAILED` (processor failure, retryable later), `PAYMENT_GATEWAY_ONE_REFUND_ONLY` (the payment gateway allows one refund per payment and this payment already had one; money is still left on it, so don't treat it as done or retry: contact support). - `mark-paid` supports methods `CASH`, `BANK_TRANSFER`, `CARD`, `QURRAH`. Omit `amount` (or equal to payment amount) for full. A partial amount reduces the original payment, marks it `SUCCEEDED`, and creates a new `PENDING` `SPLIT_REMAINDER` payment for the rest; the remainder must be more than 1 in the payment currency, and partial is not allowed while `UNDER_REVIEW`. The invoice completes only when every payment is paid. - Invoice in-place edits (`PATCH /invoices/{id}/inplace`) are for small changes such as description or scheduled date. A finalised invoice rejects actions with `INVOICE_FINALISED`. - Products and coupons used by a finalized invoice cannot be edited (`PRODUCT_USED_IN_FINALIZED_INVOICE`, `COUPON_USED_IN_FINALIZED_INVOICE`). Create a new one instead. Deleting a product price is a soft delete (archive). ### Lists, pagination, and filtering - Query params: `page` (starts at 1), `limit` (max 100), `sort_field` (default `created_at`), `sort_direction` (`asc`/`desc`, default `desc`), `search_term` (free text across names/IDs/descriptions). - Array filters repeat the key: `statuses=PENDING&statuses=PROCESSING`. In Python `requests`, pass a list. Resource-specific filters exist (e.g. `invoice_id` on payments). - Response: `{"data": [...], "pagination": {"total_count", "max_page", "current_page", "limit", "has_next_page", "has_previous_page"}}`. Loop on `has_next_page`; use `limit=100` to minimize calls. Note: the guide describes `total_count` as the count on the current page, so rely on `has_next_page` / `max_page` rather than assuming it is a global total. - When you apply filters, pagination metadata reflects the filtered set. ### Errors - Handled errors use `{"error": {"code": "...", "message": "...", "additional_info": "..."}}`. Branch on `code`, never on `message`. - Validation failures (HTTP 422) can instead return FastAPI-style `{"detail": [{"loc": [...], "msg": "...", "type": "..."}]}`. Handle **both** shapes. - Status mapping: 400 bad request, 401 unauthorized, 403 forbidden / permission, 404 not found, 410 gone, 422 unprocessable or duplicate. - Codes you should handle explicitly: `INVALID_PARAMETERS`, `DUPLICATE_CONSUMER`, `DUPLICATE_PAYMENT`, `PHONE_ALREADY_REGISTERED`, `INVOICE_FINALISED`, `PAYMENT_REFUNDED_ALREADY`, `PAYMENT_REFUNDED_FAILED`, `PAYMENT_GATEWAY_ONE_REFUND_ONLY`, `PERMISSION_FORBIDDEN`, `PRODUCT_USED_IN_FINALIZED_INVOICE`, `COUPON_USED_IN_FINALIZED_INVOICE`, `STREAM_ERROR`, `STREAM_UNKNOWN_ERROR`. On `STREAM_ERROR` / `STREAM_UNKNOWN_ERROR`, log `additional_info` and escalate to support rather than blind-retrying a money-moving call. ### Customer portal - Backend calls `POST /api/v2/consumer_portal/sessions` with `organization_consumer_id` (HTTP 201 -> `url`). The token is **short-lived and single-use**, so generate a fresh session each time the customer clicks "Manage billing". Do not cache or email the URL. - Optional body fields: `return_url` (a back-link hint only; Stream does **not** auto-redirect) and `subscription_id` (open directly on one subscription). The URL can be used for a redirect or an iframe. - The portal can only offer plan switches and add-ons if the dashboard catalog is configured: **product switch groups** (only members of the same group can replace each other; mixed MONTHLY/YEARLY allowed) and **add-on mappings** (which base products make an add-on eligible), plus the Customer Portal permission toggles. If the portal shows nothing to switch, the cause is configuration, not the API. - Subscriptions with subscription-level coupons generally cannot be edited from the portal. Proration is computed by Stream and excludes the current day; do not reimplement it. ### Branches Requests are scoped to one branch. Use `x-branch-id` to target a branch; without it the key's default branch is used. If resources seem "missing", you are probably querying the wrong branch. ### MCP server (for AI agents) - Hosted at `https://mcp.streampay.sa/mcp`. Config key `"url"`, plus `"headers": {"Authorization": "Bearer "}` for operational tools. - The resource `stream://docs/openapi` exposes the **full, current OpenAPI spec and needs no API key**. Read it before guessing request fields; this documentation set links endpoint pages whose rendered Markdown does not include the full request/response schemas. - Tool groups: payment links, customers, products, coupons, invoices (create, list, get, send, void), payments (list, get, refund). Tool names (e.g. `create_payment_link`, `refund_payment`) are not the same as REST paths. Note that some MCP descriptions (for example ZATCA-compliant invoices) are tool-level descriptions, so confirm behavior in the OpenAPI spec. ### SDKs TypeScript SDK (`StreamSDK.init(process.env.STREAM_API_KEY!)`) and an Express SDK (a `Checkout({ apiKey, ... })` route handler). Full docs live in their GitHub repositories, linked at the bottom of the Table of Contents. SDKs take the same `x-api-key` token. ### Gotchas and doc inconsistencies to be aware of - **The Installments link in the Table of Contents is malformed** (`https://docs.streampay.sa/docs/guides/installments.md`). The correct path is most likely `https://docs.streampay.sa/docs/guides/installments.md`. The installment facts above come from the same guide as published in the developer-docs full export. - The Authentication guide says "HTTP Basic Authentication" but the actual mechanism is the **`x-api-key` header carrying the Base64 token**, not an `Authorization: Basic` header. Use `x-api-key`. - The Authentication guide's curl example posts `{"name","amount"}` to `/payment_links`; that is a placeholder. A real payment link requires `items` with `product_id`s, as in the Getting Started examples. - The Pagination guide's example hits `/api/v2/customers`; the real resource path is **`/api/v2/consumers`**. - The Branches guide example calls `/api/v2/user`; the identity endpoint listed in the API reference is "Get User And Organization Info" (`/api/v2/me`-style). Check the reference for the exact path. - The branch create path may differ between exports (`/api/v2/branch` vs the public reference's "Create Branch"). Confirm in the OpenAPI spec. - Sandbox vs production: the docs reference a sandbox environment and test cards but do not publish a separate sandbox base URL. Use the sandbox-mode key/dashboard Stream gives you, or ask support, rather than inventing a hostname. - Amounts in responses appear as **decimal strings in SAR** (e.g. `"2500.00"`). Compare as decimals, not floats. - When unsure about a field name, enum value, or required property, do not guess. Read `stream://docs/openapi` via the MCP server or the endpoint's page in the Table of Contents. ### Suggested agent workflow for "add Stream payments to my app" 1. Ask which flow: one-time, subscription, installments, or embedded/redirect. Confirm whether the cart ever mixes one-time and recurring items. 2. Create (or look up) the product(s), and the consumer if the customer is known. 3. Create the payment link from the backend; return only `url` to the client. 4. Implement the success/failure routes: read `invoice_id`, call `GET /invoices/{id}`, check `status`/`amount`/`currency`, then fulfill. 5. Implement the webhook endpoint with raw-body signature verification, idempotency, and fast 2xx. Subscribe to at minimum `PAYMENT_SUCCEEDED`, `PAYMENT_FAILED`, `INVOICE_COMPLETED`, plus `PAYMENT_PARTIALLY_REFUNDED` / `PAYMENT_REFUNDED` and the `SUBSCRIPTION_*` events if you sell subscriptions. 6. Test with the sandbox cards above (and Apple Pay amount ranges) before going live. --- ## Getting Started with Stream Welcome to **Stream**, your partner for seamless and secure online payments. This guide walks you through the essentials to integrate our **checkout experience** into your website or app. The full payment flow: > Your site → Stream Secure Checkout → Redirect to your success or failure page :::tip Using an AI assistant? Point it at [`/llms.txt`](pathname:///llms.txt) for an LLM-friendly index with integration instructions (full content in [`/llms-full.txt`](pathname:///llms-full.txt)). Any docs page is also available as Markdown by appending `.md` to its URL (for example `/webhooks.md`) or by requesting it with `Accept: text/markdown`. The [MCP server](/mcp-server) gives agents direct tool access. ::: ## Overview: Integration Steps 1. [Authorization](#authorization) 1. [Create a Customer (Consumer)](#create-a-customer-consumer) 1. [Creating a Payment Link](#creating-a-payment-link) 1. [Handling Payment Redirects](#handling-payment-redirects) 1. [Retrieve Payment or Subscription Status](#retrieve-payment-or-subscription-status) --- ## Authorization All API calls require authentication using your Stream API Key Pair (`api-key` + `api-secret`). 1. Navigate to Stream [API Settings](https://app.streampay.sa/settings/api-keys). 1. Click **Create Key Pair** and store the keys securely. To authenticate your requests, encode your API key and secret as a Base64-encoded token. Use the following command (replace `api-key` and `api-secret` with your actual values): ```bash echo -n 'api-key:api-secret' | base64 ``` Include this Base64-encoded token in the `x-api-key` authentication header for all API requests: ``` x-api-key: ``` --- ## Create a Customer (Consumer) Before you can generate a payment link for a specific customer, you must first create a customer (consumer) record in Stream. This step registers the customer in your organization and returns a unique identifier that you'll use to tie payment links to that customer. ### Why Create a Customer First? - **Personalized checkout**: When you attach a customer to a payment link, Stream skips the customer-details form during checkout because the customer's information is already known. - **Customer tracking**: Every invoice, subscription, and payment is linked back to the customer record, making reconciliation straightforward. - **Repeat billing**: For recurring products, the customer record is required to manage the subscription lifecycle. ### Step 1: Prepare the Customer Data Decide which contact fields to include. The only **required** field is `name`. All other fields are optional but recommended for a complete integration. | Field | Type | Required | Description | | ------------------------- | ---------- | -------- | --------------------------------------------------------------------------- | | `name` | string | **Yes** | Full name of the customer | | `phone_number` | string | No | Phone number (E.164 format, e.g., `+966501234567`) | | `email` | string | No | Email address | | `external_id` | string | No | Your own system's ID for this customer (useful for cross-referencing) | | `iban` | string | No | IBAN (max 34 characters) for bank-related operations | | `alias` | string | No | Short alias or display name | | `comment` | string | No | Internal notes about the customer | | `preferred_language` | string | No | Customer's preferred language for communications | | `communication_methods` | string[] | No | Preferred channels: `WHATSAPP`, `EMAIL`, `SMS` (can include multiple) | > **Tip**: Always include at least `phone_number` or `email` so Stream can send payment notifications to the customer. ### Step 2: Send the Create Request - **Endpoint**: `POST /api/v2/consumers` - **Auth**: `x-api-key: ` **cURL example:** ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/consumers \ -H "x-api-key: " \ -H "Content-Type: application/json" \ -d '{ "name": "Ahmad Ali", "email": "ahmad@example.com", "phone_number": "+966501234567", "external_id": "cust_12345", "communication_methods": ["EMAIL", "SMS"] }' ``` ### Step 3: Handle the Response A successful response (`200 OK`) returns the full customer record. The most important field is `id` — this is the `organization_consumer_id` you'll use when creating payment links. **Example response (simplified):** ```json { "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Ahmad Ali", "email": "ahmad@example.com", "phone_number": "+966501234567", "external_id": "cust_12345", "is_deleted": false, "created_at": "2025-06-15T10:30:00Z", "communication_methods": ["EMAIL", "SMS"], "preferred_language": "ar" } ``` > See the full response schema in the [Create Consumer API Reference](/api/v2-consumers-create). ### Step 4: Handle Errors If the request fails validation, the API returns a `422` status with an array of error details: ```json { "detail": [ { "loc": ["body", "name"], "msg": "Field required", "type": "missing" } ] } ``` Each object in the `detail` array contains `type` (error kind), `loc` (field path), and `msg` (human-readable message). Common error scenarios: | `type` / Scenario | `loc` | `msg` (example) | Resolution | | ------------------ | ----- | ---------------- | ---------- | | `missing` | `["body", "name"]` | `"Field required"` | Include the required `name` field in the request body | | `value_error` | `["body", "phone_number"]` | `"value is not a valid phone number"` | Use E.164 format: `+` (e.g., `+966501234567`) | | `value_error` | `["body", "email"]` | `"value is not a valid email address"` | Provide a properly formatted email address | The API may also return a non-validation error with a top-level error code instead of a `detail` array. The most common one: | Error Code | Cause | Resolution | | ---------- | ----- | ---------- | | `DUPLICATE_CONSUMER` | A consumer with the same phone number or email already exists | Use [Get All Consumers](/api/v2-consumers-list) to find the existing record and use its `id` instead | > **Tip**: Always check for an existing consumer before creating a new one to avoid `DUPLICATE_CONSUMER` errors. You can list consumers with `GET /api/v2/consumers` or match by `external_id` in your own system. ### Step 5: Use the Customer ID in a Payment Link Once you have the customer `id` from the response, pass it as `organization_consumer_id` when [creating a payment link](#creating-a-payment-link). This ties the payment to the specific customer and skips the customer-details step at checkout. > **Note**: If you omit `organization_consumer_id`, the payment link will collect customer details during checkout and create a new customer record automatically. Use this approach for general-purpose links shared with multiple customers. ### Managing Existing Customers After creating customers, you can manage them with these endpoints. The `{consumer_id}` path parameter is the `id` returned by `POST /api/v2/consumers` — the same value you pass as `organization_consumer_id` when creating payment links. | Action | Method | Endpoint | API Reference | | ---------- | -------- | ------------------------------------ | ------------------------------------- | | List all | `GET` | `/api/v2/consumers` | [Get All Consumers](/api/v2-consumers-list) | | Get one | `GET` | `/api/v2/consumers/{consumer_id}` | [Get Consumer](/api/v2-consumers-get) | | Delete | `DELETE` | `/api/v2/consumers/{consumer_id}` | [Delete Consumer](/api/v2-consumers-delete) | Before creating a new customer, you can check for an existing record by listing consumers or using your `external_id` to avoid duplicates. --- ## Creating a Payment Link Create a checkout/payment link using the [Payment Link API](/api/v2-payment-links-create). - **Endpoint**: `POST /api/v2/payment_links` - **Auth**: `x-api-key: ` Payment links redirect customers to Stream's secure checkout page. They support two use cases: 1. **For multiple customers**: Create a general-purpose link that anyone can use. Each customer enters their information during checkout. Perfect for events, group purchases, or public product sales. 1. **For one specific customer**: Create a link tied to a specific customer by setting `organization_consumer_id`. The checkout page will skip the customer details collection step since the customer information is already known. Use this when charging a known customer. When a customer pays through a payment link, the behavior depends on the product types you include: - **One-time products**: When the payment link is paid, Stream creates an invoice with the products. The payment can be split into multiple installments, but the product itself is a one-time purchase (not recurring). - **Recurring products**: When the payment link is paid, Stream creates a subscription (with recurring billing) and an initial invoice. The subscription will automatically generate invoices for future billing cycles based on the recurring interval. > **Important**: You cannot mix one-time and recurring products in the same payment link. All products must be either one-time or all must be recurring. ### Strategy: Single Order with Both One-Time + Recurring Items If a cart contains both one-time and recurring products, split it into **two payment links** and guide the customer through a short two-step checkout. This keeps each payment link valid while preserving a single “order” in your system. **General approach** - Create one link that contains only **one-time** items and a separate link that contains only **recurring** items. - Treat both links as part of the same internal order (e.g., by storing a shared order reference in metadata or your database). - Present the links sequentially (or based on your business preference) so the customer completes both steps. - Confirm both outcomes via your normal status checks or webhooks before marking the order as complete. > **Note**: You'll need existing products to create payment links. See the [Products API](/api/v2-products-create) for creating products. If you want to link a payment to a specific customer, you'll also need to create a customer first using the [Consumers API](/api/v2-consumers-create). ### Example: Payment Link for Multiple Customers This example creates a payment link that can be used by multiple different customers. Each customer will enter their information when they visit the checkout page. ```json { "name": "Event Registration", "description": "Annual conference registration", "items": [ { "product_id": "your-product-uuid-here", "quantity": 1 } ], "contact_information_type": "PHONE", "currency": "SAR", "max_number_of_payments": 100, "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure", "custom_metadata": { "event_id": "conf_2025", "campaign_source": "email_marketing" } } ``` **Code snippet (general-purpose, one-time product):** ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/payment_links \ -H "x-api-key: " \ -H "Content-Type: application/json" \ -d '{ "name": "Event Registration", "description": "Annual conference registration", "items": [ { "product_id": "your-product-uuid-here", "quantity": 1 } ], "contact_information_type": "PHONE", "currency": "SAR", "max_number_of_payments": 100, "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure" }' ``` > **Note**: `organization_consumer_id` is **not set**, so the link will collect customer information from each payer. ### Example: Payment Link for One Specific Customer This example creates a payment link for a specific customer. When you specify `organization_consumer_id`, the checkout page will skip the customer details collection step since the customer information is already known. ```json { "name": "Product Purchase", "description": "One-time payment for product order", "items": [ { "product_id": "your-product-uuid-here", "quantity": 1 } ], "contact_information_type": "PHONE", "currency": "SAR", "max_number_of_payments": 1, "organization_consumer_id": "your-customer-uuid-here", "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure", "custom_metadata": { "customer_id": "cust_12345", "order_id": "order_789" } } ``` > **Note**: `organization_consumer_id` **is set**, so the checkout page will skip the customer details collection step. The `max_number_of_payments` is typically set to `1` when targeting a specific customer. ### Example: Payment Link for a Recurring Product (New Subscription) Use this when you want a customer to start a subscription from checkout. The product itself must be **recurring** (e.g., monthly), which is configured when you create the product via the [Products API](/api/v2-products-create). The payment link request is **the same endpoint** as one-time links: - **Endpoint**: `POST /api/v2/payment_links` - **Auth**: `x-api-key: ` When the customer completes payment, Stream automatically creates a **subscription** and an **initial invoice**. Future invoices are generated based on the product's recurring interval. You can retrieve the created subscription via the [Subscriptions API](/api/v2-subscriptions-list). ```json { "name": "Premium Plan Subscription", "description": "Monthly recurring plan", "items": [ { "product_id": "recurring-product-uuid-here", "quantity": 1 } ], "contact_information_type": "EMAIL", "currency": "SAR", "max_number_of_payments": 1, "organization_consumer_id": "your-customer-uuid-here", "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure", "custom_metadata": { "plan": "premium_monthly", "source": "pricing_page" } } ``` **cURL example:** ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/payment_links \ -H "x-api-key: " \ -H "Content-Type: application/json" \ -d '{ "name": "Premium Plan Subscription", "description": "Monthly recurring plan", "items": [ { "product_id": "recurring-product-uuid-here", "quantity": 1 } ], "contact_information_type": "EMAIL", "currency": "SAR", "max_number_of_payments": 1, "organization_consumer_id": "your-customer-uuid-here", "success_redirect_url": "https://example.com/success", "failure_redirect_url": "https://example.com/failure" }' ``` > **Notes**: > - The recurring behavior is defined on the **product**, not the payment link. > - Do not mix one-time and recurring products in the same payment link. > - If `organization_consumer_id` is omitted, the checkout will collect customer details and the subscription will be created for that newly created customer. ### Response The API returns a payment link object. The most important field is `url`, which you'll redirect customers to: ```json { "url": "https://streampay.sa/s/...", "id": "payment-link-uuid", "status": "ACTIVE", "amount": "2500.00", "currency": "SAR" } ``` > **Note**: This response has been simplified for brevity. The full response includes additional fields like `items`, `custom_metadata`, `success_redirect_url`, and more. See the [API Reference](/api/v2-payment-links-create) for the complete response schema. Redirect your customer to the `url` field to complete the payment securely. ### Checkout Language The checkout page language can be overridden using the `language` query parameter on the payment link URL. By default, the checkout page is displayed to the customer in the language the organization is configured in. Example: ``` https://streampay.sa/s/...?...&language=en ``` Or: ``` https://streampay.sa/s/...?language=en ``` Supported values: | Value | Language | | ------- | ---------- | | `ar` | Arabic (default) | | `en` | English | > Note: This parameter only affects the hosted checkout page UI language. Data is not affected. --- ## Handling Payment Redirects After checkout, Stream can redirect the customer to your `success_redirect_url` or `failure_redirect_url` (if provided) with payment information as query parameters. If you omit these URLs, Stream will show its hosted success/failure pages instead. ### Redirect URL Examples **Success redirect:** ``` https://example.com/success?id=...&invoice_id=...&status=paid&message=APPROVED ``` **Failure redirect:** ``` https://example.com/failure?payment_link_id=...&id=...&status=failed&message=... ``` ### Query Parameters All redirects include these parameters: | Parameter | Description | | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | `id` | Payment gateway payment ID - for internal use only. Useful for debugging when contacting support, but cannot be used in Stream APIs. Use `payment_id` or `invoice_id` instead. | | `payment_link_id` | UUID of the payment link that was used | | `status` | Payment status: `paid`, `pending`, `failed`, or `failed_internal_error` | | `message` | Status message from the gateway (e.g., `APPROVED`, `DECLINED`, `The customer’s bank has declined.`) | | `login_method` | Consumer's preferred login method: `PHONE` or `EMAIL` | :::info - **`status=failed`**: A definite rejection (e.g. insufficient funds, card declined). The payer should **retry** after addressing the issue. - **`status=failed_internal_error`**: Transient or unclear failures (e.g. timeouts). The payer should **contact support**; money may or may not have been taken. ::: **Additional parameters on success only:** | Parameter | Description | | -------------------------- | ------------------------------------------------------------------------------------------------------ | | `invoice_id` | UUID of the invoice created from the payment link | | `consent_id` | UUID of the payment consent/authorization | | `payment_id` | UUID of the payment record in Stream's system | | `organization_consumer_id` | UUID of the customer who made the payment (newly created if not set when the payment link was created) | > **Note**: On failure, the additional parameters above are not included since the payment did not complete successfully. ### Processing the Redirect Parse the query parameters from the redirect URL on your server. :::danger **Important:** Always validate the payment server-side before accepting the order or completing any business action. Fetch the invoice using the `invoice_id` from the redirect with the [Invoice API](/api/v2-invoices-get), and verify its `status`, `amount`, and `currency` match your expectations. This server-side verification ensures the payment is legitimate before updating your system state. Never trust redirect parameters alone, always verify through our API. ::: --- ## Retrieve Payment or Subscription Status Use the **Get Payment** and **Get Subscription** endpoints to fetch the latest status programmatically. **Endpoints** - **Payment status:** `GET /api/v2/payments/{payment_id}` → [Payments API](/api/v2-payments-get) - **Subscription status:** `GET /api/v2/subscriptions/{subscription_id}` → [Subscriptions API](/api/v2-subscriptions-get) **Authentication** Use the same `x-api-key` header described in [Authorization](#authorization): ``` x-api-key: ``` ### Example: Fetch Payment Status (cURL) ```bash curl -X GET https://stream-app-service.streampay.sa/api/v2/payments/your-payment-id \ -H "x-api-key: " ``` ### Example: Fetch Subscription Status (cURL) ```bash curl -X GET https://stream-app-service.streampay.sa/api/v2/subscriptions/your-subscription-id \ -H "x-api-key: " ``` ### Example: Fetch Status in JavaScript (Node.js) ```js const API_BASE = "https://stream-app-service.streampay.sa/api/v2"; const API_KEY = process.env.STREAM_API_KEY_BASE64; // base64(api-key:api-secret) async function getPaymentStatus(paymentId) { const res = await fetch(`${API_BASE}/payments/${paymentId}`, { headers: { "x-api-key": API_KEY } }); if (!res.ok) throw new Error(`Payment fetch failed: ${res.status}`); const payment = await res.json(); return payment.status; } async function getSubscriptionStatus(subscriptionId) { const res = await fetch(`${API_BASE}/subscriptions/${subscriptionId}`, { headers: { "x-api-key": API_KEY } }); if (!res.ok) throw new Error(`Subscription fetch failed: ${res.status}`); const subscription = await res.json(); return subscription.status; } ``` > **Tip**: The `status` field in each response is the source of truth for the current state. See the full response schema in the linked API reference pages. --- ## Pagination & Filtering ## Pagination Pagination helps you efficiently navigate, sort, and filter large collections of data without fetching everything at once. This is especially useful for endpoints like: - [List Payments](/api/v2-payments-list) - [List Products](/api/v2-products-list) - [List Invoices](/api/v2-invoices-list) - [List Subscriptions](/api/v2-subscriptions-list) ## Filtering Filtering is another way to efficiently navigate and filter large collections of data without fetching everything at once. Whenever pagination is applied, then so is filtering. Filtering allows you to filter your fetched objects through specific features or conditions like queries. Whenever an endpoint may return many items, Stream uses a consistent pagination and filtering structure across all list responses. --- ## Request Parameters ### Pagination Parameters You can control pagination using the following query parameters: | Parameter | Type | Description | |------------------|--------|-----------------------------------------------------------------------------| | `page` | int | Page number starting from **1**. | | `limit` | int | Number of items per page. Maximum: **100**. | | `sort_field` | string | Field used to sort the results. | | `sort_direction` | string | Either `"asc"` or `"desc"` depending on sorting direction. | By default, `sort_field` is `created_at` and `sort_direction` is `desc`. ``` GET api/v2/products?page=1&limit=20&sort_field=created_at&sort_direction=desc ``` --- ### Filtering Parameters Filtering allows you to query objects based on specific attributes. When you apply filters, the `pagination` metadata in the response will reflect the total count of items *matching* your filter, not the total count. | Parameter | Type | Description | |---------------|------------------|---------------------------------------------------------------------------------------------------| | `search_term` | `string` | A generic query string. The API searches relevant fields (e.g., names, IDs, descriptions) for matches. | | **Field Specific**| `string` / `array` | Specific attributes depending on the resource (e.g., `invoice_id`, `statuses`, `currency`). | **Note on Array Filters:** Some parameters, like `statuses`, accept multiple values. In the query string, this appears as repeating keys: `statuses=PENDING&statuses=PROCESSING` For example, the [List Payments](/api/v2-payments-list) endpoint takes filtering queries like `invoice_id` and `statuses` to filter down the returned payments. Example query: ``` GET api/v2/payments?page=1&limit=20&invoice_id=73b89d47-1bb1-443c-9a4c-f0ee23e22191&statuses=PENDING&statuses=PROCESSING ``` --- ## Pagination Response Structure Paginated responses include a `pagination` object that provides metadata about the current, previous, and next pages. | Field | Description | |--------------------|-----------------------------------------------------------------------------| | `total_count` | Number of objects returned in the current page. | | `max_page` | Maximum page number available. | | `current_page` | Page you are currently on. | | `limit` | Page size (echoes your request, capped at 100). | | `has_next_page` | Whether another page exists after this one. | | `has_previous_page`| Whether a page exists before this one. | Example response snippet: ``` { "data": [...], "pagination": { "total_count": 20, "max_page": 12, "current_page": 1, "limit": 20, "has_next_page": true, "has_previous_page": false } } ``` --- ## Examples (Python) Below are practical examples using Python's `requests` library. ### 1. Basic Pagination Fetching the first page of results with a custom limit. ```python API_KEY = "YOUR_API_KEY" BASE_URL = "https://stream-app-service.streampay.sa/api/v2/products" response = requests.get( BASE_URL, headers={"x-api-key": API_KEY}, params={ "page": 1, "limit": 20 } ) data = response.json() print(f"Showing page {data['pagination']['current_page']} of {data['pagination']['max_page']}") ``` ### 2. Global Search Filtering Using the `search_term` to find items matching a specific string (e.g., a customer name or partial ID). ```python API_KEY = "YOUR_API_KEY" BASE_URL = "https://stream-app-service.streampay.sa/api/v2/customers" response = requests.get( BASE_URL, headers={"x-api-key": API_KEY}, params={ "search_term": "JOHN DOE", # Searches for customer with that name "limit": 10 } ) results = response.json()["data"] print(f"Found {len(results)} matches for 'Al-Faisaliah'") ``` ### 3. Advanced Filtering (Lists & Specific Fields) Filtering by a specific `invoice_id` and multiple `statuses`. Note how the list of statuses is passed to the `params` dictionary. ```python API_KEY = "YOUR_API_KEY" BASE_URL = "https://stream-app-service.streampay.sa/api/v2/payments" # To filter by multiple statuses, pass them as a list payload_filters = { "page": 1, "limit": 50, "invoice_id": "73b89d47-1bb1-443c-9a4c-f0ee23e22191", "statuses": ["PENDING", "PROCESSING"] # Requests handles this as statuses=PENDING&statuses=PROCESSING } response = requests.get( BASE_URL, headers={"x-api-key": API_KEY}, params=payload_filters ) payments = response.json()["data"] for p in payments: print(f"Payment ID: {p['id']} | Status: {p['status']}") ``` ### 4. Iterating Through All Pages A robust pattern to fetch every item available. ```python API_KEY = "YOUR_API_KEY" BASE_URL = "https://stream-app-service.streampay.sa/api/v2/products" page = 1 all_products = [] while True: response = requests.get( BASE_URL, headers={"x-api-key": API_KEY}, params={"page": page, "limit": 100} # Maximize limit to reduce requests ) body = response.json() all_products.extend(body["data"]) # Stop if there are no more pages if not body["pagination"]["has_next_page"]: break page += 1 print(f"Successfully fetched {len(all_products)} products.") ``` --- --- ## Webhooks Webhooks allow your platform to receive real-time notifications from Stream when key events occur—such as payment successes, failures, or cancellations. This enables you to react to events programmatically, such as updating your database, sending notifications, or triggering internal workflows. Stream's webhook infrastructure is designed for reliability and includes features like: - Event-specific subscriptions - Secure payload signing - Delivery tracking for observability - Automatic retries using exponential backoff - One idempotency id per event, so you can recognise a repeat - An ordering value on status changes, so you can tell which change is newer ## Creating a Webhook To create or manage your webhooks, go to [Webhook Settings](https://app.streampay.sa/settings/webhooks). There you can: - Register a new webhook endpoint - Select which event types you want to subscribe to - Enable, disable, or delete webhooks ## Webhook Flow Logic Understanding which webhooks are sent in different scenarios: ### Single Payment Succeeds When a single payment succeeds: 1. `PAYMENT_SUCCEEDED` webhook is sent (one per payment) 2. If the payment completes the invoice (all payments are now paid), `INVOICE_COMPLETED` webhook is also sent Example: Invoice with 1 payment of 1000 SAR - Payment succeeds → `PAYMENT_SUCCEEDED` webhook - Invoice completes → `INVOICE_COMPLETED` webhook ### Multiple Payments Succeed (Installments) When multiple payments succeed together (e.g., installments): 1. `PAYMENT_SUCCEEDED` webhook is sent for each payment that succeeded (one per payment) 2. If all payments complete the invoice, `INVOICE_COMPLETED` webhook is also sent Example: Invoice with 3 payments of 1000 SAR each - Payments 1, 2, 3 all succeed together: - `PAYMENT_SUCCEEDED` webhook for payment_1 - `PAYMENT_SUCCEEDED` webhook for payment_2 - `PAYMENT_SUCCEEDED` webhook for payment_3 - `INVOICE_COMPLETED` webhook Example: Invoice with 5 payments, payments 1-3 succeed together: - `PAYMENT_SUCCEEDED` webhook for payment_1 - `PAYMENT_SUCCEEDED` webhook for payment_2 - `PAYMENT_SUCCEEDED` webhook for payment_3 - No `INVOICE_COMPLETED` webhook (invoice not yet fully paid) ### Payment Fails When a payment fails: 1. `PAYMENT_FAILED` webhook is sent 2. No invoice completion webhook is sent ### Payment Refunded (Partial or Full) Stream supports multiple refunds on a single payment. Webhook events depend on whether the payment is fully refunded or only partially refunded: **Partial refund** (cumulative refunded amount is still less than the payment amount): 1. `PAYMENT_PARTIALLY_REFUNDED` webhook is sent 2. Payment status becomes `PARTIALLY_REFUNDED` 3. Invoice status does not change **Full refund** (cumulative refunded amount equals the payment amount): 1. `PAYMENT_REFUNDED` webhook is sent 2. Payment status becomes `REFUNDED` 3. Invoice status does not change Example: Payment of 1000 SAR - First refund of 300 SAR → `PAYMENT_PARTIALLY_REFUNDED` (`amount_refunded` = 300, `total_amount_refunded` = 300) - Second refund of 200 SAR → `PAYMENT_PARTIALLY_REFUNDED` (`amount_refunded` = 200, `total_amount_refunded` = 500) - Final refund of 500 SAR → `PAYMENT_REFUNDED` (`amount_refunded` = 500, `total_amount_refunded` = 1000) :::info `PAYMENT_REFUNDED` means the payment is **fully** refunded. If you care about partial refunds, also subscribe to `PAYMENT_PARTIALLY_REFUNDED`. ::: ### Payment Marked as Paid When a payment is manually marked as paid: 1. `PAYMENT_MARKED_AS_PAID` webhook is sent 2. If this completes the invoice, `INVOICE_COMPLETED` webhook is also sent ### Subscription Renewal When a subscription cycle renews: 1. New invoice created → `INVOICE_CREATED` webhook 2. Payment succeeds → `PAYMENT_SUCCEEDED` webhook 3. Invoice completes → `INVOICE_COMPLETED` webhook **Note:** For subscription renewals, the `INVOICE_COMPLETED` webhook indicates that the subscription cycle has been renewed successfully. The invoice will have a `subscription_id` in its payload, and you can check if it's a renewal invoice by comparing it with previous invoices for that subscription. ## Event Types ### Payment Events - `PAYMENT_SUCCEEDED` - Payment completed successfully - `PAYMENT_FAILED` - Payment attempt failed - `PAYMENT_CANCELED` - Payment was canceled - `PAYMENT_EXPIRED` - Payment expired because its invoice passed its expiry date unpaid - `PAYMENT_PARTIALLY_REFUNDED` - A refund was issued and the payment is still only partially refunded - `PAYMENT_REFUNDED` - Payment was fully refunded - `PAYMENT_MARKED_AS_PAID` - Payment was manually marked as paid ### Invoice Events - `INVOICE_CREATED` - New invoice created - `INVOICE_SENT` - Invoice sent to consumer - `INVOICE_ACCEPTED` - Invoice accepted by consumer - `INVOICE_REJECTED` - Invoice rejected by consumer - `INVOICE_COMPLETED` - Invoice completed (all payments done) - `INVOICE_CANCELED` - Invoice canceled - `INVOICE_EXPIRED` - Invoice passed its `expires_at` date without being paid, and can no longer be paid - `INVOICE_UPDATED` - Invoice details updated ### Subscription Events - `SUBSCRIPTION_CREATED` - New subscription created - `SUBSCRIPTION_ACTIVATED` - Subscription changed to `ACTIVE` (initial activation or reactivation) - `SUBSCRIPTION_INACTIVATED` - Subscription deactivated - `SUBSCRIPTION_CANCELED` - Subscription canceled - `SUBSCRIPTION_FROZEN` - Subscription frozen - `SUBSCRIPTION_CYCLE_RENEWED_SUCCESSFULLY` - Renewal payment succeeded and the subscription was renewed - `SUBSCRIPTION_CYCLE_RENEWAL_FAILED` - Automated/tokenized renewal payment failed - `SUBSCRIPTION_CANCEL_AT_PERIOD_END` - Subscription scheduled to cancel at period end - `SUBSCRIPTION_FREEZE_NOW` - Subscription frozen immediately - `SUBSCRIPTION_UNFREEZE_NOW` - Subscription unfrozen immediately - `SUBSCRIPTION_UNFREEZE_FUTURE` - Subscription scheduled to unfreeze in future - `SUBSCRIPTION_FREEZE_CANCEL` - Subscription freeze canceled - `SUBSCRIPTION_PLAN_CHANGE_SCHEDULED` - A plan change was scheduled to take effect at `current_period_end`. - `SUBSCRIPTION_PLAN_CHANGE_CANCELED` - A previously scheduled plan change was canceled before it took effect. - `SUBSCRIPTION_PLAN_CHANGED` - The scheduled plan change was actually applied — items, coupons, interval, and amount are now live on the subscription. - `SUBSCRIPTION_PLAN_CHANGE_INVOICE_REISSUED` - While scheduling a plan change, an existing prepared next-cycle invoice was canceled and regenerated from the new target plan. This is triggered alongside `SUBSCRIPTION_PLAN_CHANGE_SCHEDULED` if it affects the plan's invoice. - `SUBSCRIPTION_PLAN_UPDATED` - Subscription plan change was applied immediately. This applies for changing seats, adding add-ons, and changing number of subscription cycles. ### Payment Link Events - `PAYMENT_LINK_PAY_ATTEMPT_FAILED` - Payment attempt failed for a payment link **Note:** This webhook is sent when a payment link payment fails. Unlike regular payment failures, no invoice, payment, or subscription entities are created on failure, so `PAYMENT_FAILED` webhook cannot be sent. This event exists specifically to notify about payment link failures when no entities exist. ## Webhook Payload The webhook POST request will have a JSON body like: ```json { "event_type": "PAYMENT_SUCCEEDED", "entity_type": "PAYMENT", "entity_id": "uuid", "entity_url": "", "status": "SUCCEEDED", "previous_status": "FAILED", "data": { /* payment or event-specific data */ }, "timestamp": "2025-07-15T14:41:21.705Z", "event_idempotency_id": "0b6f1c2e-6a3d-4f7e-9b1a-2c5d8e4f7a90", "event_occurred_at": "2025-07-15T14:41:20.913Z", "event_sorting_order": 1048213 } ``` ## Webhook Payload Example ```json { "data": { "invoice": { "id": "2df0f7e0-2634-46ab-829a-bfcb0a797d87", "url": "https://stream-app-service.streampay.sa/api/v2/invoices/2df0f7e0-2634-46ab-829a-bfcb0a797d87" }, "payment": { "id": "e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "url": "https://stream-app-service.streampay.sa/api/v2/payments/e2182d3d-b4cf-4972-bcc0-ec6d963c066d" }, "payment_link": { "id": "6361941e-3a81-4aa5-aaa6-60d6e052883a", "url": "https://stream-app-service.streampay.sa/api/v2/payment_links/6361941e-3a81-4aa5-aaa6-60d6e052883a" }, "metadata": { "customer_id": "cust_12345", "nested_data": { "sub_field": "sub_value", "sub_number": 678 }, "affiliate_id": "aff_987", "custom_field_1": "value_1", "custom_field_2": 12345, "campaign_source": "email_marketing" } }, "status": "SUCCEEDED", "previous_status": "PENDING", "entity_id": "e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "timestamp": "2025-07-22T14:40:31.485576", "event_idempotency_id": "7c1e9a52-3f0b-4d61-8a2e-5b9f0c6d1e34", "event_occurred_at": "2025-07-22T14:40:30.912044Z", "event_sorting_order": 1048213, "entity_url": "https://stream-app-service.streampay.sa/api/v2/payments/e2182d3d-b4cf-4972-bcc0-ec6d963c066d", "event_type": "PAYMENT_SUCCEEDED", "entity_type": "PAYMENT" } ``` ## Webhook Request Headers - `Content-Type: application/json` - `User-Agent: StreamApp-Webhook/1.0` - `X-Webhook-Event`: Event type (e.g., `PAYMENT_SUCCEEDED`) - `X-Webhook-Entity-Type`: Entity type (e.g., `PAYMENT`) - `X-Webhook-Entity-ID`: Entity UUID - `X-Webhook-Event-Idempotency-ID`: The event's `event_idempotency_id` (same value as in the body) - `X-Webhook-Signature`: Format: `t={timestamp},v1={signature}` - `timestamp` is the UNIX timestamp when the signature was generated. - `signature` is an HMAC-SHA256 of `{timestamp}.{payload}` using your webhook’s `secret_key`. - `X-Webhook-Timestamp`: The timestamp used in the signature. ## Verifying Webhook Authenticity :::warning Always verify the `X-Webhook-Signature` before treating a webhook as authentic or updating your system (fulfillment, access, financial state). Reject requests with a missing or invalid signature. Unsigned or unverified payloads could be forged; never trust the JSON body alone. ::: To verify a webhook: 1. Extract the `X-Webhook-Signature` header and split into timestamp and signature. 2. Compute the HMAC-SHA256 of `{timestamp}.{raw_request_body}` using your webhook’s `secret_key`. 3. Compare your computed signature to the value in the header. Example (Python): ```python def verify_webhook_signature(secret: str, raw_body: bytes, signature_header: str): # signature_header: "t=TIMESTAMP,v1=SIGNATURE" parts = dict(x.split('=') for x in signature_header.split(',')) timestamp = parts['t'] signature = parts['v1'] message = f"{timestamp}.{raw_body.decode()}" computed = hmac.new(secret.encode(), message.encode(), hashlib.sha256).hexdigest() return hmac.compare_digest(computed, signature) ``` ## Duplicates and ordering Stream delivers every webhook **at least once**. The same event can reach you more than once: after a retry, a manual re-send from the dashboard, or a recovery on our side. Webhooks are also **not delivered in order**: a later change can arrive before an earlier one. Every webhook body carries these fields: | Field | On | Meaning | |---|---|---| | `event_idempotency_id` | every webhook | One id per event. It is the same on every retry and re-send, and the same for every endpoint that receives the event. Also sent as the `X-Webhook-Event-Idempotency-ID` header. | | `event_occurred_at` | every webhook | When the change happened (UTC). `timestamp` stays the time the webhook was built. | | `event_sorting_order` | status webhooks | For one payment, invoice or subscription, a later change has a higher value. Values are not consecutive, so a gap does not mean you missed an event. `null` on notices. | | `previous_status` | payment, invoice and subscription status webhooks | The status before this change. `null` on notices and plan-change webhooks. | **Status webhooks** report a change of the entity's status. Their `status` is the status the entity moved to: - Payments: `PAYMENT_SUCCEEDED`, `PAYMENT_FAILED`, `PAYMENT_CANCELED` - Invoices: `INVOICE_SENT`, `INVOICE_ACCEPTED`, `INVOICE_REJECTED`, `INVOICE_COMPLETED`, `INVOICE_CANCELED` - Subscriptions: `SUBSCRIPTION_ACTIVATED`, `SUBSCRIPTION_INACTIVATED`, `SUBSCRIPTION_CANCELED`, `SUBSCRIPTION_FROZEN` - Plan changes: `SUBSCRIPTION_PLAN_CHANGE_SCHEDULED`, `SUBSCRIPTION_PLAN_CHANGE_CANCELED`, `SUBSCRIPTION_PLAN_CHANGED`, `SUBSCRIPTION_PLAN_UPDATED`, `SUBSCRIPTION_PLAN_CHANGE_INVOICE_REISSUED`. Their `status` is the subscription's status when the change was made. **Notices** report something other than a status change: every other event type, including refunds, `PAYMENT_MARKED_AS_PAID`, `INVOICE_CREATED`, `INVOICE_UPDATED`, renewals, freezes, `SUBSCRIPTION_CANCEL_AT_PERIOD_END` and `PAYMENT_LINK_PAY_ATTEMPT_FAILED`. Their `status` field is not the entity's current status. For a refund, read the refund's state from `event_type` and `data`. ### How to handle them 1. **De-duplicate on `event_idempotency_id`.** Store the ids you have processed, and acknowledge a repeat with a `2xx` without acting on it again. 2. **Process every event**, even one that arrives late. Each partial refund, for example, carries its own facts. 3. **Keep the entity's status from the status webhook with the highest `event_sorting_order`.** If a status webhook arrives with a lower value than one you already applied, record it but do not move the status back. 4. **When in doubt, fetch the entity** from `entity_url` to read its current state. ```python def handle_webhook(body: dict) -> None: if already_processed(body["event_idempotency_id"]): return # a repeat: acknowledge with 2xx and do nothing record_event(body) # every event is processed, including late ones order = body.get("event_sorting_order") if order is not None and order > last_applied_order(body["entity_id"]): set_status(body["entity_id"], body["status"], order) mark_processed(body["event_idempotency_id"]) ``` :::note Webhooks created before these fields were introduced do not carry them, and neither does a re-send of such a webhook. Treat a missing `event_idempotency_id` as "no id": de-duplicate those by `entity_id`, `event_type` and `status`, or fetch the entity. ::: ## Webhook Delivery & Retry Logic - Delivery Attempts: Every webhook event triggers one delivery record per endpoint. Each delivery attempt and its status (pending, delivered, failed, retrying) is tracked for auditing. Retries and manual re-sends reuse the same delivery record and send the same `event_idempotency_id`. - Retry Schedule: If your endpoint does not respond with a 2xx status, Stream will retry delivery up to 5 times. The default retry delays (in minutes) are: 1. 1st retry: 5 minutes after the first failure 2. 2nd retry: 30 minutes after the second failure 3. 3rd retry: 2 hours (120 minutes) after the third failure 4. 4th retry: 6 hours (360 minutes) after the fourth failure 5. 5th retry: 12 hours (720 minutes) after the fifth failure After the fifth attempt, if delivery is still unsuccessful, the webhook delivery is marked as failed and no further attempts will be made. - Auditing: All delivery attempts, responses, and errors are logged and can be audited. --- ## Testing Cards ## Testing Environment In order to test your application without having to go live with cards and accounts, you can use [Moyasar's testing cards](https://docs.moyasar.com/guides/card-payments/test-cards/)) to simulate different transaction outcomes. The test cards should be used in a sandbox environment. This is also applicable if you are using the Stream's UI in sandbox mode and want to test the flow without having to use actual cards. ## Required Card Fields Below are the values that need to be entered for the non-card number fields when testing: | Field | Value | | :--- | :--- | | **Name** | Any name made of two words separated by a space (e.g., John Doe) | | **Year** | Any **future** year | | **Month** | Any month (or a future month if using the current year) | | **CVC** | Any 3 digits (4 digits for American Express (AMEX)) | --- ## List of Test Cards and Expected Outcomes Below is the list of test card numbers you can use in your test environment to simulate specific transaction statuses (Success/Failure) according to the card network. ### Mada | Card Number | Status | Message | Response Code | 3DS Note | | :--- | :--- | :--- | :--- | :--- | | `4201320111111010` | **paid** | APPROVED | 00 | ---- | | `4201320000013020` | **failed** | UNSPECIFIED FAILURE | 99 | ---- | | `4201320000311101` | **failed** | INSUFFICIENT FUNDS | 51 | ---- | | `4201320131000508` | **failed** | DECLINED: LOST CARD | 41 | ---- | | `4201321234411220` | **failed** | DECLINED | 05 | ---- | | `4201322267774310` | **failed** | DECLINED: EXPIRED CARD | 54 | ---- | | `4201326324640570` | **failed** | DECLINED: EXCEEDS WITHDRAWAL LIMIT | 61 | ---- | | `4201321144311528` | **failed** | DECLINED: STOLEN CARD | 43 | ---- | ### Visa | Card Number | Status | Message | Response Code | 3DS Note | | :--- | :--- | :--- | :--- | :--- | | `4111114005765430` | **paid** | APPROVED | 00 | Frictionless Authentication | | `4111111111111111` | **paid** | APPROVED | 00 | ---- | | `4123120000000000` | **failed** | UNSPECIFIED FAILURE | 99 | ---- | | `4123120001090000` | **failed** | INSUFFICIENT FUNDS | 51 | ---- | | `4123450131000508` | **failed** | DECLINED: LOST CARD | 41 | ---- | | `4123120001090109` | **failed** | DECLINED | 05 | ---- | | `4123128518640738` | **failed** | DECLINED: EXPIRED CARD | 54 | ---- | | `4123123033308648` | **failed** | DECLINED: EXCEEDS WITHDRAWAL LIMIT | 61 | ---- | | `4123125276780003` | **failed** | DECLINED: STOLEN CARD | 43 | ---- | | `4111118250252531` | **failed** | 3DS: attempted but not available, please ensure that you have enabled Online Purchase from your bank portal. | ---- | ECI 06 | | `4111113343111067` | **failed** | 3DS service error occurred. | ---- | 3DS fails during enrollement check | | `4111116611600661` | **failed** | The card is not enrolled in 3DS service. | ---- | ---- | | `4111112205628150` | **failed** | 3DS service error occurred. | ---- | 3DS fails during authentication attempt | | `4111115784228433` | **failed** | The authentication attempt was rejected by the issuer bank. | ---- | ---- | | `4111115620358287` | **failed** | The authentication is unavailable, please try again later or contact issuer bank if problem persisted. | ---- | ---- | ### Mastercard | Card Number | Status | Message | Response Code | 3DS Note | | :--- | :--- | :--- | :--- | :--- | | `5421080101000000` | **paid** | APPROVED | 00 | ---- | | `5105105105105100` | **failed** | UNSPECIFIED FAILURE | 99 | ---- | | `5457210001000092` | **failed** | INSUFFICIENT FUNDS | 51 | ---- | | `5204010101000000` | **failed** | DECLINED: LOST CARD | 41 | ---- | | `5204730000002514` | **failed** | DECLINED | 05 | ---- | | `5105107550274126` | **failed** | DECLINED: EXPIRED CARD | 54 | ---- | | `5105106475101067` | **failed** | DECLINED: EXCEEDS WITHDRAWAL LIMIT | 61 | ---- | | `5105107304607225` | **failed** | DECLINED: STOLEN CARD | 43 | ---- | ### American Express (AMEX) | Card Number | Status | Message | Response Code | 3DS Note | | :--- | :--- | :--- | :--- | :--- | | `340000000900000` | **paid** | APPROVED | 00 | ---- | | `371111111111114` | **failed** | UNSPECIFIED FAILURE | 99 | ---- | | `340033000000000` | **failed** | INSUFFICIENT FUNDS | 51 | ---- | | `340012340501000` | **failed** | DECLINED: LOST CARD | 41 | ---- | | `340033000000133` | **failed** | DECLINED | 05 | ---- | | `340000018441278` | **failed** | DECLINED: EXPIRED CARD | 54 | ---- | | `340000753060788` | **failed** | DECLINED: EXCEEDS WITHDRAWAL LIMIT | 61 | ---- | | `340000418501838` | **failed** | DECLINED: STOLEN CARD | 43 | ---- | --- ## Testing Apple Pay Unlike card payments where specific test card numbers are used, testing **Apple Pay** payments in the Stream's sandbox environment is based on the **amount** sent to the API (according to [Moyassar](https://docs.moyasar.com/guides/apple-pay/testing/)). A **real card** must be added to an Apple Pay Wallet to test the process, but you must be using the sandbox environment to ensure no actual payment is made. The following amounts will simulate different payment outcomes: | Amount (Minor Unit) | Amount (SAR) | Status | Message | Response Code | | :--- | :--- | :--- | :--- | :--- | | `20000` to `30000` | `200.00` to `300.00` | **paid** | APPROVED | 00 | | `100000` to `110000` | `1000.00` to `1100.00` | **failed** | UNSPECIFIED FAILURE | 99 | | `110100` to `120000` | `1101.00` to `1200.00` | **failed** | INSUFFICIENT FUNDS | 51 | | `120100` to `130000` | `1201.00` to `1300.00` | **failed** | DECLINED: LOST CARD | 41 | | `130100` to `140000` | `1301.00` to `1400.00` | **failed** | DECLINED | 05 | | `140100` to `150000` | `1401.00` to `1500.00` | **failed** | DECLINED: EXPIRED CARD | 54 | | `150100` to `160000` | `1501.00` to `1600.00` | **failed** | DECLINED: EXCEEDS WITHDRAWAL LIMIT | 61 | | `160100` to `170000` | `1601.00` to `1700.00` | **failed** | DECLINED: STOLEN CARD | 43 | > **Note:** Moyasar accepts the payment amount in the **minor currency unit** (e.g., cents), and the test environment uses this amount to return different results. --- > **Tip:** Using any other amount range than the stated above will result in the payment failing. --- ## Installments Installments allow customers to split a payment into multiple smaller payments over time. Customers can choose from the installment options you configure when paying an invoice or payment link. > Note: Installments are only available for one-time products. They are automatically disabled for recurring products (subscriptions). --- ## How Installments Work When a customer selects an installment option, Stream automatically calculates the amount for each installment and schedules them based on the split period. Each installment becomes a separate payment with its own due date. ![Customer selecting installment split option](/img/installment-split-selection.png) **Example:** 1,000 SAR split into 3 monthly installments: - Installment 1: 333.33 SAR (due on payment date) - Installment 2: 333.33 SAR (due 1 month later) - Installment 3: 333.34 SAR (due 2 months later) --- ## How Installment Amounts Are Calculated Installment amounts depend on the option: the total can be split by percentage (equal or custom shares) or into fixed amounts, optionally after a down payment. If the amount doesn't divide evenly, any rounding difference is added to the last installment to ensure the total always equals the original payment amount. For example, 999.98 SAR split into 3 equal installments results in: 333.33 SAR, 333.33 SAR, and 333.32 SAR (the last installment is reduced by 0.01 SAR to account for the rounding difference). > Note: The total of all installments always equals the original payment amount. --- ## Configuration Configure installment settings in your [Payment Settings](https://app.streampay.sa/settings/payment-settings). Invoice and payment link settings are configured separately. ### Enable/Disable Installments #### API When creating an invoice via the [Invoices API](/api/v2-invoices-create) or a payment link via the [Payment Links API](/api/v2-payment-links-create), you can enable or disable installments with the `payment_methods` parameter. Set `installment: true` to enable installments or `installment: false` to disable them for that specific invoice or payment link. For payment links, this setting overrides the organization's default payment link installment settings. If you don't include the `payment_methods` parameter, the organization's default settings will be used. #### Settings Page You can configure the default installment settings in your [Payment Settings](https://app.streampay.sa/settings/payment-settings): - **For invoices**: Enable or disable installments in the invoice payment options - **For payment links**: Enable or disable installments in the payment link payment options (these defaults apply when creating payment links via the UI or when the API request doesn't specify `payment_methods`) ### Split Options Configure the installment options available for customers to choose from, including the number of installments (2 to 52) and the split period, the interval between installments (from monthly up to yearly). Each option can use a different split period. ### Minimum Amount The minimum installment amount is 100 SAR per installment by default. If the payment amount divided by the number of installments is less than 100 SAR, that installment option will not be available. For example, with a payment of 250 SAR: - 2 installments: 125 SAR each ✅ (available) - 3 installments: 83.33 SAR each ❌ (not available, below minimum) The minimum amount cannot be changed through the API or dashboard. Contact Stream support to modify this value. --- ## Payment Plans and Which One Applies Installment options are grouped into payment plans, configured in your [Payment Settings](https://app.streampay.sa/settings/payment-settings). Invoices and payment links have separate plans, and each plan is set for one currency. | Plan | Applies to | Notes | | --- | --- | --- | | **Main payment plan** | Any amount not covered by a custom plan | One per currency for invoices and one for payment links. It cannot be deleted, but it can be disabled. | | **Custom plan** | Totals within a minimum and maximum amount (inclusive) | Ranges cannot overlap. | | **Override plan** | Only the invoices or payment links you assign it to | Has a name and is never applied automatically. See [Override Plans](#override-plans). | Stream picks the plan for an invoice or payment link in this order: 1. **Override plan**: if one is assigned and enabled, its options are offered whatever the amount. 2. **Custom plan**: if the total falls within a custom plan's range, that plan is used. 3. **Main payment plan**: used for every other amount. A disabled plan turns installments off for everything it would apply to. For example, if you disable the main payment plan, installments are off by default but are still offered for amounts covered by an enabled custom plan. If a custom plan covers the amount but is disabled, installments are off for that amount. They don't fall back to the main payment plan. --- ## Split Types and Down Payment Each installment option splits the total in one of two ways. ### Percentage Each installment is a percentage of the total. Choose the number of installments, then enter a percentage for any installment you want to set. Percentages you enter are used as is, and the rest of the 100% is split equally across the installments you leave blank. All installments must add up to 100%. For example, with 3 installments: - No percentages entered: 33.33% each - 50% entered for the first installment: 50%, 25%, 25% ### Fixed Amount Each installment is a fixed amount, and the number of installments depends on the total. If the total doesn't divide evenly: - A remainder of 10 SAR or more becomes its own final installment. This final installment may be below the minimum installment amount. - A smaller remainder is added to the last installment. For example, with a fixed amount of 300 SAR: - 1,050 SAR: 300, 300, 300, 150 SAR - 905 SAR: 300, 300, 305 SAR ### Down Payment An option can start with a fixed down payment. The down payment is charged first, and the rest of the total is split by the option's percentages or fixed amount. The down payment must be at least 10 SAR and less than the total. For example, 1,000 SAR with a 250 SAR down payment and three equal installments gives 250 SAR now, then three installments of 250 SAR. --- ## Coupons on Payment Plans You can attach coupons to a payment plan to reward a customer's choice: - **Option coupon**: applied when the customer picks that installment option. - **Full-price coupon**: applied when the customer pays the full amount instead of choosing installments. It's only shown when the payment has installment options. --- ## Override Plans Use an override plan to offer a specific plan to a particular customer or deal, regardless of the amount. Create the override plan in your [Payment Settings](https://app.streampay.sa/settings/payment-settings), then copy its ID from the plan's menu: ![Copy ID option in the payment plan menu](/img/payment-plan-copy-id.png) Pass the ID as `installment_rule_override_id` when creating the invoice or payment link: ```json { "installment_rule_override_id": "" } ``` - The plan must be an enabled override plan with at least one option, for the same context (invoice or payment link) and the same currency. Otherwise the request fails with `INSTALLMENT_OVERRIDE_RULE_NOT_AVAILABLE`. - The customer is offered only that plan's options. The minimum installment amount still applies. - On an invoice, the override can be changed until the invoice is split into installments. On a payment link, it can only be set when the link is created. - If an assigned override plan is later disabled, installments are turned off for that invoice or payment link. If it's deleted, the normal plan selection applies again. - Editing a plan changes what unpaid invoices and payment links using it offer. Invoices already split into installments keep their schedule. --- ## Installments Start Date By default, the second installment is due one split period after the first payment. Set `installments_start_date` to choose the second installment's due date. Later installments follow on the option's split period from that date. **Example:** a monthly option with 3 installments and an invoice due on January 1: - Without `installments_start_date`: installments are due January 1, February 1 and March 1. - With `installments_start_date` set to February 4: installments are due January 1, February 4 and March 4. The start date can be set on invoices and, at creation only, on payment links. For a payment link: - The start date must be later than `created_resource_effective_at`, or later than now if that field isn't set. - The first payment is due on `created_resource_effective_at`, or when the customer pays. - It can't be set on subscription, trial or metered payment links, or on links where installments are turned off. --- ## Authentication Learn how to authenticate your API requests to the Stream platform. ## Overview All API calls to Stream require authentication using your API Key Pair. Stream uses a simple but secure authentication method where you encode your credentials and include them in every request. ## Getting Your API Keys 1. Log in to your Stream dashboard 2. Navigate to [API Settings](https://app.streampay.sa/settings/api-keys) 3. Click **Create Key Pair** 4. Store your `api-key` and `api-secret` securely 5. Copy `x-api-key` to use in the APIs or you can gernerate later :::warning Important Your API secret should be kept secure and never exposed in client-side code or public repositories. Treat it like a password. ::: ## Authentication Methods Stream uses HTTP Basic Authentication with Base64 encoding of your API credentials. Encode your API key and secret as a Base64-encoded token: ```bash echo -n 'api-key:api-secret' | base64 ``` **Example:** ```bash echo -n '038cb769-9ce3-49da-9d52-17fd49bf07e8:6ea68e79-8756-4be8-9bd2-307314e8d12c' | base64 # Output: MDM4Y2I3NjktOWNlMy00OWRhLTlkNTItMTdmZDQ5YmYwN2U4OjZlYTY4ZTc5LTg3NTYtNGJlOC05YmQyLTMwNzMxNGU4ZDEyYw== ``` #### Using the Token Include the Base64-encoded token in the `x-api-key` header for all API requests: ```bash curl -X POST https://stream-app-service.streampay.sa/api/v2/payment_links \ -H "x-api-key: MDM4Y2I3NjktOWNlMy00OWRhLTlkNTItMTdmZDQ5YmYwN2U4OjZlYTY4ZTc5LTg3NTYtNGJlOC05YmQyLTMwNzMxNGU4ZDEyYw==" \ -H "Content-Type: application/json" \ -d '{ "name": "Test Payment", "amount": 100.00 }' ``` ### Using SDKs When using Stream SDKs, authentication is handled automatically. Simply provide your `x-api-key` during initialization: #### TypeScript SDK ```typescript const client = StreamSDK.init(process.env.STREAM_API_KEY!); ``` #### Express SDK ```typescript app.get( "/checkout", Checkout({ apiKey: process.env.STREAM_API_KEY!, // ... other config }) ); ``` --- ## Branches in the API API requests are always scoped to a single branch. When creating an API key, you specify which branches it can access. For each request, you can select the target branch, which determines where resources are created and accessed. ## Creating API Keys with Branch Access When creating an API key, you can specify: - Branches: List of specific branches the API key can access - Default Branch: Default branch used when `x-branch-id` header is not provided - Is All Branches: If `true`, the API key has access to all branches, present and future ## Selecting a Branch in API Requests Include the `x-branch-id` header to specify which branch to use for that request: ```bash curl -X GET https://stream-app-service.streampay.sa/api/v2/user \ -H "x-api-key: YOUR_API_KEY" \ -H "x-branch-id: branch-uuid-here" ``` If `x-branch-id` is omitted, the API key's `default_branch_id` is used. ## Branch Access Validation The API key must have access to the branch specified in `x-branch-id`: - If `is_all_branches=true`: Access to all organization branches - Otherwise: Only branches listed in `branch_ids` Requests to unauthorized branches return a 4xx error. --- ## Customer Portal (Hosted Billing) # Customer Portal (hosted billing) The **customer portal** is Stream’s hosted web app ([billing.streampay.sa](https://billing.streampay.sa)) where your **consumers** sign in and manage their relationship with **you**, within limits you configure in Stream: subscriptions (plan changes, quantity adjustment, and add‑ons allowed by your catalog), invoices, saved cards, profile and language, and payment flows that use Stream checkout. --- ## Prerequisites - **Consumer in Stream** — The person must exist as an **organization consumer** (Stream’s customer record). Create one with the [Create Consumer](/api/v2-consumers-create) API (or your existing consumer flow) and use the returned **`id`** as **`organization_consumer_id`** when creating a portal session. - **Merchant API credentials** — Your backend calls Stream with **`x-api-key`**; see [Authentication](/authentication). --- ## Send a consumer to the portal Call from your **server** only (never expose your API secret or full key pair in a browser or app) this [endpoint](/api/v2-consumer-portal-sessions-create) to get the one-time use token to open the customer portal for a specific consumer ID. **Body (minimum)** | Field | Required | Description | | ----- | -------- | ----------- | | `organization_consumer_id` | Yes | The consumer’s UUID in Stream (`id` from [Create Consumer](/api/v2-consumers-create) or [list consumers](/api/v2-consumers-list)). | **Response** On success (**HTTP 201**) the JSON includes a **`url`**. Return that **`url`** to your frontend and open it so the consumer lands on the billing portal. You can optionally include **`return_url`** (query hint for “back to merchant”; Stream does not auto-redirect), **`subscription_id`** to open a specific subscription for that consumer, or other optional fields supported by the API—see the reference for the full request schema. --- ## What subscription self-service means When your settings allow it, a customer can change an **active** subscription from the portal. Stream validates every change against your catalog and portal rules. Below is what each kind of change means in plain terms. ### Switching plans **Plan switching** is when the customer moves from one **base** subscription product to another **member of the same product switch group** you defined in Stream. Only products you placed in that group can replace one another; the portal does not allow arbitrary jumps across unrelated products. Plans with different recurring cycles (e.g MONTHLY and YEARLY) can be added in the same switch group. Typical shape of a switch: one billed **base** line is removed and another **base** line (the new plan) replaces it within the rules of that group. Whether this appears as an immediate change or is scheduled depends on billing setup and proration logic (see [Proration and timing](#proration-and-timing)). :::note Coupons Subscriptions with **coupon** locked at subscription level usually **cannot** be edited from the portal. Coupons on lines you keep can persist; lines you remove lose their coupons. ::: ### Add-ons **Add-ons** are separate catalog products attached to an active subscription—not the main plan by itself. Each add-on is only available when the subscription’s **base** catalog products make it eligible. You declare that relationship in Stream (which bases may carry which add-ons). Customers can subscribe or drop add-ons in the portal only when you enable **add / remove add-ons** for Customer Portal and the add-on mapping allows it. When creating an add-on, you get to choose a list of recurring products for which the add-on is eligible. In case a subscription has multiple recurring products and the recurring products have different eligible add-ons, the customer will be able to add **all** of these add-ons. ### Changing quantity Quantity changes behave differently depending on whether the line is part of your **switch group** (often “seat-like” bases) versus an **add-on**: | Kind of line | What “quantity” means | How you control it | | ------------ | --------------------- | ------------------ | | **Products in switch groups** | How many seats or units apply to that **base plan** row | Toggle **switch-group quantity change** in Customer Portal settings. When enabled, you can constrain **minimum** and **maximum** quantities; when disabled, customers cannot freely change those quantities in the portal. | | **Add-on lines** | How many units of that add-on are on the subscription | Toggle **add-on quantity change**. When quantity change is **off** for new add-ons, new add-ons are typically limited to quantity **one** until you widen the rule. | The portal compares changes to **allowed** quantities only; anything outside configured bounds is rejected. ### Proration and timing {#proration-and-timing} **Proration** is how billing adjusts when the subscription **mid-cycle** gains or loses value: Stream compares what was prepaid or owed for the current period against what the revised subscription implies, and settles the difference—often creating an invoice line or prompting payment **before** the next renewal. Proration does not include the current day in the new pricing. For example, if a monthly subscription (30 days) was created today and then in the same day an add-on gets added immediately through proration, the proration excludes the current day from the new bill (i.e. the user pays 29 / 30 days worth of add-on instead of 30/30.) Roughly: - **Adding add-ons**, **raising quantity**, or some **plan upgrades** commonly produce **immediate** charges (or payment steps) when money is owed, because billing value rises right away relative to what was invoiced. - **Removing add-ons**, **lowering quantity**, or changing plans in directions that reduce or reshape future billing often take effect according to billing rules. For example at **period end** or as a **scheduled** change rather than forcing an instant upfront payment in every case. - When a change crosses into a **different billing rhythm** than the subscription’s targets, moves are **often scheduled** for a future boundary rather than squeezed into an immediate payment-only flow inside the portal. From the customer’s perspective, the portal either **confirms the change outright**, **shows a payment or card step** when an adjustment is due now, or **explains that the change applies later** in the billing period—depending on the scenario above. Until any required payment clears, billing may remain on the previous shape until reconciliation finishes. Exact math and timing depend on your products’ recurrence and Stream’s reconciliation; you do **not** re-implement proration in your integration. --- ## Configure Customer Portal, branding, and catalog Open the Stream dashboard, then **[Settings → Customer Portal](https://app.streampay.sa/settings/customer-portal)**. There you tune both **permissions** customers get and **branding** of [billing.streampay.sa](https://billing.streampay.sa). ### Portal permissions (toggles) These settings mirror what you enable in Customer Portal Settings in the UI—they define what edits the hosted app even offers: | Setting | Meaning for your customers | | ------- | -------------------------- | | **Product switch** | Can move between products you grouped in **product switch groups** (plan changes within your allowed set). | | **Add / remove add-ons** | Can attach or remove add-ons you exposed through add-on eligibility. | | **Switch-group quantity change** | Can change quantity on **base** lines that belong to switch groups, within optional **min** / **max** when enabled. | | **Add-on quantity change** | Can change quantity on add-on lines, within optional **min** / **max** when enabled. | | **Subscription cancellation** | Customer-led cancellation inside portal flows is on or off. | ### Branding On the same **Customer Portal** settings area, you can personalize the hosted experience: - **Primary color** and **secondary color** — Applied across the portal UI so it feels closer to your brand. - **Favicon** — Shown in the browser tab when customers use the billing site. Uploads and color pickers persist with your organization so every session link inherits the same look. ### Catalog prerequisites (beyond the toggles) Customer Portal switches and add-ons only work if the **catalog** is set up to match: | Goal | What to set up in Stream | | ---- | ------------------------- | | Allowed plan moves | Create **product switch groups** and assign which products belong to each group. Only members of the **same** group can replace one another. | | Which add-ons exist for which bases | Maintain **add-on mappings**: for each add-on product, declare which **base** products make it eligible. | Until those mappings exist, toggles alone will not expose meaningful switches or add-ons in the portal. --- ## Summary | Role | Responsibility | | ---- | ---------------- | | **Your backend** | `POST /api/v2/consumer_portal/sessions` with `organization_consumer_id`, then return **`url`** to the client. | | **Your frontend** | Open **`url`**; do not use the merchant API key in the browser. | | **billing.streampay.sa** | Hosts the customer portal once the consumer opens **`url`. | For API key setup and authentication, see [Authentication](/authentication). --- ## Embedded Checkout Render a payment link checkout in-page with the Stream Embed SDK. Create a payment link via the API first, then pass the response **`url`** into `paymentLink`. Details on creating links (products, consumers, redirects): [Creating a Payment Link](/#creating-a-payment-link). ## Prerequisites - Same setup as payment-link creation: API key pair, and at least one product ID. See [Creating a Payment Link](/#creating-a-payment-link). ### Apple Pay Register each hostname where the checkout is embedded. Open **[Settings → Company profile → Apple Pay domains](https://app.streampay.sa/settings/company-profile)**, then: 1. Add the exact hostname where the checkout loads. `example.com` and `www.example.com` are registered separately. Leave off `https://` and any page path. 2. Download the verification file there and host it, unchanged, at `https://.well-known/apple-developer-merchantid-domain-association`. Keep the file name exactly as downloaded (no `.txt` or other extension). Serve it over HTTPS with no redirect, and allow public access to `.well-known`. 3. Choose **Verify domain**. Apple Pay shows on that hostname once the status is **Registered**. ## Example ### 1. Create a payment link `POST /api/v2/payment_links` returns an object whose **`url`** field is what you embed (same value you would redirect to). ```bash curl -s -X POST https://stream-app-service.streampay.sa/api/v2/payment_links \ -H "x-api-key: " \ -H "Content-Type: application/json" \ -d '{ "name": "Checkout", "items": [{ "product_id": "your-product-uuid-here", "quantity": 1 }], "contact_information_type": "PHONE", "currency": "SAR", "max_number_of_payments": 100 }' ``` Example response (trimmed): ```json { "url": "https://streampay.sa/ds/..." } ``` Use that `url` as `paymentLink` in the next step. Build the request body you need (customer-specific links, metadata, redirect URLs, subscriptions, etc.) using the guide and [Create payment link](https://docs.streampay.sa/api/v2-payment-links-create). ### 2. Embed checkout Load the default SDK, mount a container, call `Stream.Checkout` with the **`url`** from step 1. Inject the URL from your server—do not create payment links or expose API keys in frontend-only code. ```html ``` ## Options | Option | Type | Required | Description | | ------ | ---- | -------- | ----------- | | `paymentLink` | `string` | **Yes** | Full payment-link URL from the API (`url` field) or short ID Stream accepts | | `container` | `string` \| `Element` | **Yes** | CSS selector or DOM element for the iframe | | `minHeightPx` | `number` | No | Min iframe height (default **280**) | | `maxHeightPx` | `number` | No | Max iframe height (default **920**) | | `vhCapPx` | `number` | No | Viewport-relative height cap (default **800**) | | `vhFraction` | `number` | No | Viewport fraction for fluid height (default **0.7**) | ## See also - [Webhooks](/webhooks) — confirm payment server-side - [Public API reference](https://docs.streampay.sa/) --- ## Stream API Errors This page documents the error response format and the standardized error codes returned by Stream API endpoints. The goal is to provide a stable, predictable contract for client applications and integrators. ## Error response envelope All handled errors return a response body in this format: ```json { "error": { "code": "STREAM_ERROR", "message": "Something wrong happened, please contact support.", "additional_info": "Optional human-readable details" } } ``` - `code`: A stable error code from `StreamErrorCodes`. - `message`: A user‑facing message associated with the code. - `additional_info`: Optional, best‑effort details to aid debugging. ## HTTP status codes | HTTP status | Meaning | | --- | --- | | 400 | The request is invalid. | | 401 | The API key is missing or invalid. | | 403 | The API key doesn't have permission for this action or resource. | | 404 | The resource doesn't exist. | | 409 | Another request changed the invoice or payment at the same time, or is still changing it. The `code` says whether to retry; see [Invoice and payment errors](#invoice-and-payment-errors). | | 410 | The resource is no longer available. | | 422 | The request failed validation, or a value conflicts with an existing record. | | 503 | A temporary failure on Stream's side; nothing was changed. Retry after a short wait. | ## Stream error codes The following codes are used across all Stream API endpoints: | Code | Message | | --- | --- | | `STREAM_ERROR` | Something wrong happened, please contact support. | | `STREAM_UNKNOWN_ERROR` | Unknown exception happened; this exception will be handled as soon as possible. | | `PHONE_ALREADY_REGISTERED` | Phone is already registered. | | `INVALID_PARAMETERS` | Request input is not valid. | | `INVOICE_FINALISED` | Invoice is finalised and cannot undergo this action. | | `PAYMENT_REFUNDED_ALREADY` | Duplicate action; payment has already been refunded. | | `PAYMENT_REFUNDED_FAILED` | Could not refund payment; processor failed. | | `PAYMENT_GATEWAY_ONE_REFUND_ONLY` | The payment gateway allows only one refund per payment, and this payment has already been refunded once. Money is still left on the payment; contact support to refund the rest. | | `DUPLICATE_CONSUMER` | Consumer already exists. | | `DUPLICATE_PAYMENT` | A payment with the given information already exists. | | `PERMISSION_FORBIDDEN` | Permission forbidden. | | `PRODUCT_USED_IN_FINALIZED_INVOICE` | Product cannot be updated; it is used by a finalized invoice. | | `COUPON_USED_IN_FINALIZED_INVOICE` | Coupon cannot be updated; it is used by a finalized invoice. | ## Invoice and payment errors These codes come from invoice and payment actions. Several of them mean another request is working on the same invoice or payment at the same moment, for example a payer paying while you cancel. In that case the whole request is undone: nothing was changed, and a retry is safe unless the table says otherwise. | Code | HTTP | Returned by | What happened | What to do | | --- | --- | --- | --- | --- | | `INVOICE_ROW_LOCKED` | 409 | Invoice cancel and edit, subscription cancel and uncancel, mark a payment as paid, refund, auto-charge on demand | Another action is updating the same invoice or its payments right now: a payment, refund, cancellation, edit, accounting sync or the automatic expiry. | Retry after a few minutes. Auto-charge on demand: fetch the payment first; the card may already have been charged. | | `INVOICE_CANCEL_CONFLICT` | 409 | Invoice cancel, subscription cancel | The invoice changed while it was being canceled. | Fetch the invoice again, then retry if it still needs canceling. | | `INVOICE_REACTIVATION_CONFLICT` | 409 | Subscription uncancel | The subscription's next invoice changed while it was being reactivated. | Fetch the subscription again, then retry. | | `INVOICE_REACTIVATION_BLOCKED` | 409 | Subscription uncancel | The payer's card was charged for the subscription's canceled invoice and that charge hasn't been returned yet, so the subscription can't be uncanceled. | Don't retry; contact Stream support. | | `INVOICE_EXPIRED` | 400 | Mark a payment as paid, auto-charge on demand | The invoice passed its expiry date (`expires_at`) unpaid and can no longer be paid. `additional_info` holds the invoice id. | Don't retry. Create a new invoice if the payer still needs to pay. | | `INVOICE_EXPIRY_CONFLICT` | 409 | Auto-charge on demand | The invoice changed while it was being expired. | Fetch the invoice again; if it's expired, see `INVOICE_EXPIRED`. | | `PAYMENT_SUCCESS_CONFLICT` | 409 | Mark a payment as paid, auto-charge on demand | The payment changed while its success was being recorded. | Mark as paid: fetch the payment, then retry if it isn't paid. Auto-charge on demand: fetch the payment first; the card may already have been charged. | | `PAYMENT_LATE_CHARGE_EXPIRED` | 409 | Auto-charge on demand | The invoice expired while the card was being charged. The charge went through, and Stream is returning the full amount to the card. | Don't retry. The payer is notified; create a new invoice if they still need to pay. | | `PAYMENT_LATE_CHARGE_CANCELED` | 409 | Auto-charge on demand | The invoice was canceled while the card was being charged. The charge went through, and Stream is returning the full amount to the card. | Don't retry. The payer is notified. | | `PAYMENT_REFUND_CONFLICT` | 409 | Refund | The payment changed while its refund was being recorded. Nothing was refunded. | Fetch the payment, then retry. | | `PAYMENT_REFUND_BUSY` | 409 | Refund | The payment is being updated by another process. Nothing was refunded. | Retry after a few minutes. | | `PAYMENT_REFUND_NOT_RECORDED` | 409 | Refund | The refund went through at the payment gateway but couldn't be saved yet. It is recorded automatically shortly after. | **Don't refund again**: the payer has been (or is being) refunded, and a retry would refund twice. | | `PAYMENT_REFUND_PENDING` | 400 | Refund | An earlier refund on this payment is still pending at the payment gateway. Nothing was refunded. | Retry once the pending refund completes (check the payment's `refunds`). | | `PAYMENT_REFUND_NOT_SENT` | 400 | Refund | The refund didn't reach the payment gateway. Nothing was refunded. | Retry later. | | `PAYMENT_REFUND_OUTCOME_UNKNOWN` | 400 | Refund | The payment gateway returned an error without confirming the refund, which may still go through. | Check the payment's `refunds` before trying again. | A `503` with code `STREAM_ERROR` can come from any of these actions when a Stream service is briefly unavailable. Nothing was changed; retry after a short wait. ### Invoice expiry date (`expires_at`) Creating an invoice (`POST /v2/invoices`) or changing it (`PUT /v2/invoices/{invoice_id}`, `PATCH /v2/invoices/{invoice_id}/inplace`) with an `expires_at` that breaks a rule returns `400` with code `STREAM_ERROR` and the reason in `additional_info`: | `additional_info` | Meaning | | --- | --- | | `expires_at is only supported for one-off invoices` | Only one-off invoices can expire; installment and recurring invoices can't. | | `expires_at must be in the future` | The expiry time has already passed. | | `expires_at must be after scheduled_on` | The expiry must be later than the invoice's due date. | | `expires_at can't be changed for an invoice in status ` | The expiry can only be changed while the invoice is DRAFT, CREATED or SENT (`PUT`), or CREATED (`PATCH /inplace`). | An `expires_at` without a timezone (for example `2026-12-01T10:00:00` instead of `2026-12-01T10:00:00Z`) returns `422`. The expiry edit can also return `INVOICE_ROW_LOCKED` (above). --- ## Stream MCP Server MCP (Model Context Protocol) is a standard way for AI clients to call tools and read resources from external systems. The Stream MCP Server exposes Stream operations (payments, invoices, customers, products, etc.) as MCP tools so clients like Claude Desktop, Cursor, and VS Code can use them directly. **Resources vs tools:** MCP **resources** (such as the OpenAPI documentation) do not require a Stream API key. **Tools** that call the Stream API—payments, customers, invoices, products, coupons, and the rest, **do** require a valid key in your client configuration. ## Main Feature: API Documentation Integration The primary feature of this MCP server is direct integration with Stream API documentation. - It exposes the full OpenAPI spec as an MCP resource. - AI clients can read the latest API schema and stay aligned with current endpoints. - This improves tool accuracy for request fields, validation, and endpoint usage. ## Hosted endpoint Stream hosts the MCP server at: `https://mcp.streampay.sa/mcp` Configure your client to use this URL. Include `Authorization` when you use tools that hit the Stream API; you can omit it if you only read documentation resources. Use the **Connect MCP** button at the top of this page to install the server in Cursor, VS Code, or LM Studio, or to copy the command, URL, or JSON config for other clients. Paste your Stream API key into the optional field in its menu to include the `Authorization` header in the generated config; the key stays in your browser and is never sent anywhere. Without a key, only documentation resources work. --- ## Client configuration (Claude Desktop / Cursor / VS Code) Add this to your MCP config file (`claude_desktop_config.json` or `mcp.json`). Use the `headers` block whenever you rely on tools that require the Stream API (omit it for resources-only use, such as the OpenAPI spec). ```jsonc { "mcpServers": { "stream": { "url": "https://mcp.streampay.sa/mcp", "headers": { // Required for operational tools (payments, customers, etc.); omit if you only read docs resources (e.g. OpenAPI). "Authorization": "Bearer stream_api_key_here" } } } } ``` --- ## Available Tools ### Payment Links | Tool | Description | |---|---| | `create_payment_link` | Create a new checkout / payment link | | `list_payment_links` | Paginated list with optional status filter | | `get_payment_link` | Get a single payment link by ID | | `deactivate_payment_link` | Deactivate / archive a payment link | ### Customers | Tool | Description | |---|---| | `create_customer` | Create a customer with name, email, phone, metadata | | `list_customers` | Paginated list of customers | | `get_customer` | Get a single customer by ID | | `update_customer` | Update customer fields | | `delete_customer` | Soft-delete a customer | ### Products | Tool | Description | |---|---| | `create_product` | Create a one-time or recurring product | | `list_products` | List products with optional type filter | | `get_product` | Get a single product by ID | | `update_product` | Update product name, description, or price | | `archive_product` | Archive a product | ### Coupons | Tool | Description | |---|---| | `create_coupon` | Create a fixed or percentage discount coupon | | `list_coupons` | List coupons with optional status filter | | `get_coupon` | Get a single coupon by ID | | `deactivate_coupon` | Deactivate a coupon | ### Invoices | Tool | Description | |---|---| | `create_invoice` | Create a ZATCA-compliant invoice | | `list_invoices` | List invoices with filters | | `get_invoice` | Get a single invoice by ID | | `send_invoice` | (Re)send an invoice via email / SMS | | `void_invoice` | Void / cancel an unpaid invoice | ### Payments | Tool | Description | |---|---| | `list_payments` | List payments with filters | | `get_payment` | Get payment details | | `refund_payment` | Issue a full or partial refund | ### Resources Reading these resources does not require your Stream API key in the client (unlike the operational tools above). | Resource URI | Description | |---|---| | `stream://docs/openapi` | Full Stream OpenAPI spec (cached, auto-refreshed) — main documentation integration feature | --- ## Add Product Price `POST /api/v2/products/{product_id}/prices` Add a new price to a product in a different currency. Each product can have one active price per currency. The currency must be enabled in the organization's currency configuration. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product | Request body (required) Content type: `application/json` Type: object. DTO for creating a new product price. - `currency` (string, required): ISO 4217 currency code (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (number | string, required): Price amount (must be >= 1 for non-metered products; metered products can use up to 12 decimal places) - `is_price_inclusive_of_vat` (boolean, optional): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. (default `true`) - `is_price_exempt_from_vat` (boolean, optional): If True, no VAT applies to this price (default `false`) ## Responses ### 201: Successful Response Content type: `application/json` Type: object. DTO for product price response. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `amount_in_smallest_unit` (integer): Price amount in smallest currency unit (e.g. halala for SAR). ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Auto Charge On Demand `POST /api/v2/payments/auto-charge-on-demand/{payment_id}` Charge a payment using the consumer's latest tokenized card. This endpoint allows organizations to charge a payment using the consumer's latest active tokenized card. The following conditions must be met: - The consumer must have at least one active tokenized card. - The payment must be in an unpaid status (PENDING, PROCESSING, FAILED, etc.). **This is a restricted API and is only available to some organizations.** ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment to charge | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `payment_id` (string (uuid)): ID of the payment that was charged - `invoice_id` (string (uuid)): ID of the invoice associated with the payment ### 400: If no active card exists, payment is already paid, or payment processing fails. ### 401: If the organization does not have access to this API. ### 404: If payment, consumer, card, or consent is not found. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Cancel an invoice `POST /api/v2/invoices/{invoice_id}/cancel` Cancels an invoice and marks it as `CANCELED`. Use this when the invoice should no longer be collected or shown as payable. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `invoice_id` | path | string (uuid) | yes | | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `invoice_number` (integer): Global unique invoice number - `remaining_amount` (string): Remaining amount to be paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `paid_amount` (string): Total amount already paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `organization_consumer` (object): Consumer information for this invoice - `id` (string (uuid4)) - `name` (string) - `alias` (string, nullable) - `email` (string (email), nullable) - `phone_number` (string (phone), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `consumer_type` (string): (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Address response model. ``address_line_1``/``address_line_2`` mirror ``street``/``district`` for existing clients (the dashboard's customer pages still read them). - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable) - `commercial_registration` (string, nullable) - `consumer` (object, nullable) - `id` (string (uuid4)) - `phone_number` (string (phone), nullable) - `email` (string (email), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `is_deleted` (boolean, nullable) - `communication_methods` (array, nullable): (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `items` (array): List of items included in the invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `product` (object): Product details for this invoice item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `quantity` (integer): Quantity of the product in this invoice item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `unit_price` (string, nullable): Snapshotted unit price at invoice creation (for historical accuracy) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item (for traceability) - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `branch` (object, nullable): Branch information for this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `payments` (array): List of payments associated with this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the payment - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `scheduled_on` (string (date-time)): Scheduled date and time for the payment - `invoice_payment_number` (integer): Payment number within the invoice - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `settled_at` (string (date-time), nullable): Date and time when the payment was settled - `refunded_at` (string (date-time), nullable): Date and time when the payment was refunded - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `pdf_link` (string, nullable): URL to the payment PDF document - `paid_to_account_id` (string (uuid4), nullable): Unique identifier (UUID) of the account the payment was made to - `viban_wallet_transaction_id` (string (uuid4), nullable): The vIBAN wallet DEBIT transaction that paid this payment; absent when none did - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if this invoice is part of a subscription - `subscription` (object, nullable): Subscription details if this invoice is part of a subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. - `payment_methods` (object, nullable): Payment methods available for this invoice - `mada` (boolean, required): Enable Mada payment method - `visa` (boolean, required): Enable Visa payment method - `mastercard` (boolean, required): Enable Mastercard payment method - `amex` (boolean, required): Enable American Express payment method - `bank_transfer` (boolean, required): Enable bank transfer payment method - `installment` (boolean, required): Enable installment payment option - `qurrah` (boolean, optional): Enable Qurrah payment method (default `false`) - `bnpl` (boolean, optional): Enable BNPL (e.g. Tamara) for this invoice (default `false`) - `bnpl_eligibility` (object, nullable): Latest BNPL eligibility for this invoice (provider display name + help message) - `eligible` (boolean) - `provider_name` (string) - `message` (string, nullable) - `recurrence_pattern` (string, nullable): Recurrence pattern for recurring invoices (one of `Hour`, `Day`, `Week`, `Fortnight`, `Month`, `Quarter`, `Half-Year`, `Year`) - `parent_id` (string (uuid4), nullable): Parent invoice ID for recurring invoices - `url` (string): URL to access the invoice - `beneficiaries` (array, nullable): Beneficiaries linked to this invoice - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `adjustments` (array): Credit, debit, and amendment history for this invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `type` (string): (one of `CREDIT`, `DEBIT`, `AMENDMENT`) - `adjustment_reason` (string): (one of `ERROR_IN_PRICING`, `CHANGE_IN_PRODUCT_OR_SERVICE`, `CHANGE_IN_TERM_AND_CONDITIONS`, `OTHER`) - `net_amount_change` (string): (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changed_by` (string): (one of `USER`) - `changed_by_user_id` (string (uuid), nullable) - `products` (array) - `side` (string): (one of `OLD`, `NEW`) - `product_id` (string (uuid)) - `quantity` (integer) - `coupons` (array) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `coupons` (array) - `side` (string): (one of `OLD`, `NEW`) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `total_credited` (string): Sum of credit adjustment amounts (absolute value of negative net changes) (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_debited` (string): Sum of debit adjustment amounts (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_refunded` (string): Sum of payment refunds on this invoice (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `net_received` (string): Sum of paid payment amounts minus total_refunded (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `remaining_amount_in_smallest_unit` (integer): Remaining amount in smallest currency unit. - `paid_amount_in_smallest_unit` (integer): Paid amount in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Cancel Scheduled Subscription Plan Change `DELETE /api/v2/subscriptions/{subscription_id}/pending-change` Cancel a previously-scheduled deferred plan change. No-op (still 200) when no SCHEDULED pending change exists. If the original schedule call had already re-issued the next-cycle invoice (Arm B), the new invoice remains unchanged — it represents the upcoming cycle the consumer was notified about. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Cancel Subscription `POST /api/v2/subscriptions/{subscription_id}/cancel` Schedule or complete cancellation and optionally cancel related invoices. Behavior depends on subscription **status**: - **ACTIVE**: Cancellation is **scheduled for the end of the current billing period** (the subscription stays active until then; it is not moved to ``CANCELED`` immediately). - **INACTIVE**, **TRIALING**, **TRIAL_PENDING**: The subscription is **canceled immediately** (status becomes ``CANCELED``). Use ``cancel_related_invoices`` to also cancel ongoing invoices tied to this subscription. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription to cancel | Request body (required) Content type: `application/json` Type: object - `cancel_related_invoices` (boolean): Whether or not to cancel all the related invoices to this subscription. If False, only the subscription will be canceled but the related invoices will remain untouched. (default `false`) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Branch `POST /api/v2/branch` Create a new branch for the organization. If a branch with the same name already exists, returns the existing branch. ## Request Request body (required) Content type: `application/json` Type: object - `name` (string, required): Branch name. Must be unique within the organization. (min length 1; max length 100) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `name` (string) - `user_count` (integer, nullable) - `created_at` (string (date-time)) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Consumer `POST /api/v2/consumers` Create a new consumer with contact information and payment details. ## Request Request body (required) Content type: `application/json` Type: object. Consumer creation model. - `name` (string, required): Consumer name (max length 512) - `phone_number` (string (phone), nullable, optional): Phone number - `email` (string (email), nullable, optional): Email address - `external_id` (string, nullable, optional): External ID (max length 512) - `iban` (string, nullable, optional): IBAN (max length 34) - `alias` (string, nullable, optional): Alias (max length 512) - `comment` (string, nullable, optional): Comment (max length 512) - `preferred_language` (string, nullable, optional): Preferred language (one of `AR`, `EN`) - `communication_methods` (array, nullable, optional): Communication methods (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `consumer_type` (string, optional): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable, optional): Address (required for business type) - `street` (string, required): Street name (alias: address_line_1) - `district` (string, nullable, optional): District (alias: address_line_2) - `building_number` (string, nullable, optional): Building number (4 digits for Saudi addresses) (max length 255) - `city` (string, required): City - `postal_code` (string, nullable, optional): Postal code - `country` (string, required): Country - `vat_number` (string, nullable, optional): VAT number (optional for business type) (max length 64) - `commercial_registration` (string, nullable, optional): Commercial registration number (optional for business type) (max length 512) - `beneficiaries` (array, nullable, optional): Associated entities to create with this consumer (optional) - `name` (string, required): Associated entity name - `fields` (object, optional): Catalog field values for this associated entity (keys from GET /resource-fields) - `fields` (object, optional): Catalog field values for this consumer (keys from GET /resource-fields?resource_type=consumer) - `external_metadata` (object, optional): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `email` (string (email), nullable): Email address of the consumer - `external_id` (string, nullable): External identifier for the consumer - `consumer` (object, nullable): Consumer information - `id` (string (uuid4), nullable): Unique identifier (UUID) of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `iban` (string, nullable): IBAN (International Bank Account Number) of the consumer - `is_deleted` (boolean): Whether the consumer has been deleted - `alias` (string, nullable): Alias of the consumer - `created_at` (string (date-time)): Date and time when the consumer was created - `branch` (object): Branch information for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `comment` (string, nullable): Additional comments or notes about the consumer - `communication_methods` (array): Preferred communication methods for the consumer (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `preferred_language` (string): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`) - `address` (object, nullable): National address (required for business type) - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number (optional for business type) - `commercial_registration` (string, nullable): Commercial registration number (optional for business type) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `beneficiaries` (array): List of beneficiaries - `id` (string (uuid4)): Unique identifier (UUID) of the beneficiary - `name` (string): Name of the beneficiary - `fields` (object): Catalog field values for this associated entity - `fields` (object): Catalog field values for this consumer - `last_invoice_activity` (object, nullable): Information about the most recent invoice activity for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `org_invoice_number` (integer): Organization-specific invoice number - `subcription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if applicable ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Coupon `POST /api/v2/coupons` Create a new coupon with discount details and active/inactive status. ## Request Request body (required) Content type: `application/json` Type: object - `name` (string, required): Name of the coupon. (min length 1; max length 80) - `discount_value` (number | string, required): Discount value of the coupon (either percentage or fixed). - `currency` (string, nullable, optional): Currency code for fixed-amount coupons (required when is_percentage=false). Must be null when is_percentage=true. Must be one of the supported currency codes. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean, optional): True if the discount is a percentage, False if it is a fixed amount. (default `false`) - `is_active` (boolean, optional): Indicates if the coupon is active upon creation. (default `true`) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Invite For A User To Join The Organization By Email `POST /api/v2/organization/invite` Send an email invitation for a user to join the organization. An invitation email will be sent to the specified address with a link to accept the invitation. The caller can invite to the whole organization only as an organization admin, and to a branch only where they hold ``members:write``. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `language` | header | string | no | (one of `AR`, `EN`; default `"AR"`) | Request body (required) Content type: `application/json` Type: object - `email` (string (email), required): Email address of the user to invite. May already be registered; rejected only if they are already a member of this organization. - `bindings` (array, required) - `role_id` (string (uuid), required) - `branch_id` (string (uuid), nullable, optional) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)) - `email` (string (email)) - `organization_id` (string (uuid)) - `expire_at` (string (date-time)) - `created_by` (string (uuid)) - `bindings` (array) - `role_id` (string (uuid), required) - `branch_id` (string (uuid), nullable, optional) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Invoice `POST /api/v2/invoices` Create a new invoice with items and payment details. Important: For most use cases, use the Checkout/Payment Link API (`/v2/payment_links`) instead. It generates a payment link that you can embed in your own web page or redirect to. Use Cases: - Create an invoice and manually mark it as paid for reference - Automated invoice generation ## Request Request body (required) Content type: `application/json` Type: object. DTO for creating a new invoice. Multi-Currency Support: - The `currency` field is optional and defaults to 'SAR' for backward compatibility. - When a currency is specified, products must have a price in that currency. - If no ProductPrice exists for the currency, falls back to product.price (legacy). - `notify_consumer` (boolean, optional): Whether to send a notification to the consumer about the invoice (default `true`) - `description` (string, nullable, optional): Invoice description or notes (min length 1; max length 512) - `items` (array, required): List of products or services to include in the invoice - `product_id` (string (uuid4), required): UUID of the product to include - `quantity` (integer, required): Quantity of the product - `coupons` (array, nullable, optional): List of coupon UUIDs to apply for discounts on this specific item - `payment_methods` (object, required): Payment methods allowed for this invoice - `mada` (boolean, required): Enable Mada payment method - `visa` (boolean, required): Enable Visa payment method - `mastercard` (boolean, required): Enable Mastercard payment method - `amex` (boolean, required): Enable American Express payment method - `bank_transfer` (boolean, required): Enable bank transfer payment method - `installment` (boolean, required): Enable installment payment option - `qurrah` (boolean, optional): Enable Qurrah payment method (default `false`) - `bnpl` (boolean, optional): Enable BNPL (e.g. Tamara) for this invoice (default `false`) - `coupons` (array, nullable, optional): List of coupon UUIDs to apply for discounts - `organization_consumer_id` (string (uuid4), required): UUID of the consumer who will pay this invoice - `organization_consumer_beneficiaries` (array, nullable, optional): UUID of the beneficiaries to the consumer who will pay this invoice - `scheduled_on` (string (date-time), required): Invoice due date - `installment_rule_override_id` (string (uuid4), nullable, optional): ID of the installment rule to use as an override for this invoice. If null, the default rule is used. Cannot be changed once the invoice is split into installments. - `installments_start_date` (string (date-time), nullable, optional): When the invoice is split into installments, this date anchors the due dates of subsequent installments. Example: for a monthly plan split into 3 installments, with scheduled_on set to Jan 1: If installments_start_date is null, the subsequent installments are due on Feb 1 and Mar 1. If installments_start_date is Feb 4, they are due on Feb 4 and Mar 4. - `expires_at` (string (date-time), nullable, optional): Optional expiry for one-off invoices, with a timezone (e.g. 2026-12-01T10:00:00Z). If the invoice is still unpaid and not yet accepted when this time passes, it becomes EXPIRED and can no longer be paid. Must be in the future and after scheduled_on. - `currency` (string, optional): Currency for the invoice. Defaults to SAR for backward compatibility. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `accounting_external_id` (string, nullable, optional): The accounting system's own record id (e.g. Zoho invoice_id) for a pre-existing invoice this invoice should be reconciled against instead of creating a new document. (max length 512) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `invoice_number` (integer): Global unique invoice number - `remaining_amount` (string): Remaining amount to be paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `paid_amount` (string): Total amount already paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `organization_consumer` (object): Consumer information for this invoice - `id` (string (uuid4)) - `name` (string) - `alias` (string, nullable) - `email` (string (email), nullable) - `phone_number` (string (phone), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `consumer_type` (string): (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Address response model. ``address_line_1``/``address_line_2`` mirror ``street``/``district`` for existing clients (the dashboard's customer pages still read them). - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable) - `commercial_registration` (string, nullable) - `consumer` (object, nullable) - `id` (string (uuid4)) - `phone_number` (string (phone), nullable) - `email` (string (email), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `is_deleted` (boolean, nullable) - `communication_methods` (array, nullable): (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `items` (array): List of items included in the invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `product` (object): Product details for this invoice item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `quantity` (integer): Quantity of the product in this invoice item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `unit_price` (string, nullable): Snapshotted unit price at invoice creation (for historical accuracy) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item (for traceability) - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `branch` (object, nullable): Branch information for this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `payments` (array): List of payments associated with this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the payment - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `scheduled_on` (string (date-time)): Scheduled date and time for the payment - `invoice_payment_number` (integer): Payment number within the invoice - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `settled_at` (string (date-time), nullable): Date and time when the payment was settled - `refunded_at` (string (date-time), nullable): Date and time when the payment was refunded - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `pdf_link` (string, nullable): URL to the payment PDF document - `paid_to_account_id` (string (uuid4), nullable): Unique identifier (UUID) of the account the payment was made to - `viban_wallet_transaction_id` (string (uuid4), nullable): The vIBAN wallet DEBIT transaction that paid this payment; absent when none did - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if this invoice is part of a subscription - `subscription` (object, nullable): Subscription details if this invoice is part of a subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. - `payment_methods` (object, nullable): Payment methods available for this invoice - `mada` (boolean, required): Enable Mada payment method - `visa` (boolean, required): Enable Visa payment method - `mastercard` (boolean, required): Enable Mastercard payment method - `amex` (boolean, required): Enable American Express payment method - `bank_transfer` (boolean, required): Enable bank transfer payment method - `installment` (boolean, required): Enable installment payment option - `qurrah` (boolean, optional): Enable Qurrah payment method (default `false`) - `bnpl` (boolean, optional): Enable BNPL (e.g. Tamara) for this invoice (default `false`) - `bnpl_eligibility` (object, nullable): Latest BNPL eligibility for this invoice (provider display name + help message) - `eligible` (boolean) - `provider_name` (string) - `message` (string, nullable) - `recurrence_pattern` (string, nullable): Recurrence pattern for recurring invoices (one of `Hour`, `Day`, `Week`, `Fortnight`, `Month`, `Quarter`, `Half-Year`, `Year`) - `parent_id` (string (uuid4), nullable): Parent invoice ID for recurring invoices - `url` (string): URL to access the invoice - `beneficiaries` (array, nullable): Beneficiaries linked to this invoice - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `adjustments` (array): Credit, debit, and amendment history for this invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `type` (string): (one of `CREDIT`, `DEBIT`, `AMENDMENT`) - `adjustment_reason` (string): (one of `ERROR_IN_PRICING`, `CHANGE_IN_PRODUCT_OR_SERVICE`, `CHANGE_IN_TERM_AND_CONDITIONS`, `OTHER`) - `net_amount_change` (string): (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changed_by` (string): (one of `USER`) - `changed_by_user_id` (string (uuid), nullable) - `products` (array) - `side` (string): (one of `OLD`, `NEW`) - `product_id` (string (uuid)) - `quantity` (integer) - `coupons` (array) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `coupons` (array) - `side` (string): (one of `OLD`, `NEW`) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `total_credited` (string): Sum of credit adjustment amounts (absolute value of negative net changes) (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_debited` (string): Sum of debit adjustment amounts (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_refunded` (string): Sum of payment refunds on this invoice (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `net_received` (string): Sum of paid payment amounts minus total_refunded (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `remaining_amount_in_smallest_unit` (integer): Remaining amount in smallest currency unit. - `paid_amount_in_smallest_unit` (integer): Paid amount in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Metered Subscription `POST /api/v2/metered_subscriptions` Create a new metered subscription linking a METERED product to an organization consumer. The subscription is active immediately when its start time is reached. Usage can begin as soon as the subscription exists, and billing will use the subscription's billable window. ## Request Request body (required) Content type: `application/json` Type: object. Metered subscription creation request. Includes product_id (must be METERED type), organization_consumer_id, and optional start and end times. - `product_id` (string (uuid), required): METERED product ID (product.price is the price per unit) - `organization_consumer_id` (string (uuid), required): Organization consumer ID - `starts_at` (string (date-time), nullable, optional): When subscription becomes effective (defaults to now) - `ends_at` (string (date-time), nullable, optional): When subscription expires (null = no expiry) ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Response for metered subscription. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)) - `product_id` (string (uuid)) - `organization_consumer_id` (string (uuid)) - `organization_id` (string (uuid)) - `starts_at` (string (date-time)) - `ends_at` (string (date-time), nullable) - `created_at` (string (date-time)) - `updated_at` (string (date-time), nullable) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Payment Link `POST /api/v2/payment_links` Create a new checkout/payment link for collecting payments. - **One-time products**: Creates an invoice (with its associated payment) when paid. - **Recurring products**: Creates a subscription (with its associated invoice and payment) when paid. **Notes:** - Cannot mix one-time and recurring products in the same payment link. - Installments are automatically disabled for recurring products (subscriptions). - Invoices, subscriptions and payments are created only after a successful payment. ## Request Request body (required) Content type: `application/json` Type: object - `name` (string, required): Name of the payment link (max length 512) - `description` (string, nullable, optional): Optional description of the payment link (max length 512) - `currency` (string, optional): Currency for the payment link (e.g. SAR, USD). All products must have a price in this currency. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `items` (array, required): List of products to include in the payment link - `product_id` (string (uuid4), required): Unique identifier (UUID) of the product to include in the payment link - `quantity` (integer, optional): Quantity of the product. Must be at least 1. (default `1`; min 1) - `coupons` (array, optional): List of coupon UUIDs to apply to this specific item for discounts - `allow_custom_quantity` (boolean, optional): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable, optional): Minimum quantity allowed if allow_custom_quantity is True; value is inclusive (min 0) - `max_quantity` (integer, nullable, optional): Maximum quantity allowed if allow_custom_quantity is True; value is inclusive (min 0) - `coupons` (array, optional): List of coupon UUIDs to apply at the payment link level for discounts - `max_number_of_payments` (integer, nullable, optional): Maximum number of times this payment link can be used. If null or 0, the payment link can be used unlimited times; 0 is normalized to null. If organization_consumer_id is set, this number becomes how many times that specific customer can pay. Typically this should be set to 1 in that scenario. (min 1) - `valid_until` (string (date-time), nullable, optional): Datetime after which the payment link is no longer valid. If no timezone is specified, UTC is assumed. - `created_resource_effective_at` (string (date-time), nullable, optional): Datetime when the resource created from this payment link becomes effective. It is used as the one-off payment's scheduled_on, the recurring subscription's period_start, or the metered subscription's starts_at. If no timezone is specified, UTC is assumed. - `confirmation_message` (string, nullable, optional): Optional message to display to the payer after successful payment (max length 512) - `payment_methods` (object, nullable, optional): Configure which payment methods are available. If null, organization defaults are used. Note: Installments are always disabled for recurring products (subscriptions). - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable, optional): ID of the installment rule to use as an override at checkout for invoices created from this payment link. If null, the default rule is used. Follows the corresponding invoice field behavior. Must be null for subscription and metered-subscription payment links. - `installments_start_date` (string (date-time), nullable, optional): Date used to anchor the due dates of subsequent installments when an invoice created from this payment link is split into installments. Follows the corresponding invoice field behavior. Must be null for subscription and metered-subscription payment links. - `trial_period_days` (integer, nullable, optional): Free trial duration (in days) for subscriptions created from this link. Only valid when the link contains recurring (subscription) products. Must be between 1 and 365. Omit (or null) for no trial. (min 1; max 365) - `custom_fields` (object, nullable, optional): JSON Schema (https://json-schema.org/specification) to define and validate fields collected from payers during payment. Only string type properties allowed. - `success_redirect_url` (string (uri), nullable, optional): URL to redirect the payer to after a successful payment (min length 1; max length 2000) - `failure_redirect_url` (string (uri), nullable, optional): URL to redirect the payer to after a failed payment (min length 1; max length 2000) - `organization_consumer_id` (string (uuid), nullable, optional): ID of an existing consumer who will pay using this payment link. If set, customer information is not collected and this payment will be for that customer only. This is typically used when a specific customer is paying once. If not set, the link will collect customer information first. Use this when you expect multiple payments from different people, such as for a group trip or event. - `custom_metadata` (object, nullable, optional): Optional key-value metadata dictionary for attaching custom information. This metadata will be included as-is in payment link responses and webhook payloads. - `contact_information_type` (string, nullable, optional): Type of contact information required for payment collection. Defaults to PHONE if not specified. (one of `PHONE`, `EMAIL`) - `document_ids` (array, optional): IDs of documents (previously uploaded via POST /v2/payment_links/documents) to attach to this payment link. - `form_id` (string (uuid), nullable, optional): ID of a form to attach. Only one form can be attached per payment link. ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link - `name` (string): Name of the payment link - `description` (string, nullable): Description of the payment link - `amount` (string): Total payment link amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original payment link amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the payment link - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment link (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation; for SAR links or when converted from other currencies. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate from link currency to home currency (SAR) at creation time (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `max_number_of_payments` (integer, nullable): Maximum number of times this payment link can be used - `valid_until` (string (date-time), nullable): UTC datetime after which the payment link is no longer valid - `created_resource_effective_at` (string (date-time), nullable): UTC datetime when the resource created from this payment link becomes effective - `confirmation_message` (string, nullable): Message to display to the payer after successful payment - `recurring_interval` (string, nullable): Billing cycle interval if this payment link creates a subscription (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring payments - `trial_period_days` (integer, nullable): Free trial duration (in days) for subscriptions created from this link. Only meaningful for recurring (subscription) products. When set, each consumer who subscribes via this link gets a free trial of this length, after which the first real billing period begins. Must be between 1 and 365. - `status` (string): Current status of the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the payment link - `organization_consumer_id` (string (uuid4), nullable): Unique identifier (UUID) of the organization consumer if linked to a specific consumer - `deactivate_message` (string, nullable): Message to display when the payment link is deactivated - `custom_fields` (object, nullable): Custom fields schema for collecting additional information - `success_redirect_url` (string, nullable): URL to redirect the payer to after a successful payment - `failure_redirect_url` (string, nullable): URL to redirect the payer to after a failed payment - `custom_metadata` (object, nullable): The key-value metadata dictionary passed during creation. - `contact_information_type` (string, nullable): Type of contact information required for payment collection (one of `PHONE`, `EMAIL`) - `items` (array): List of products included in the payment link - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `quantity` (integer): Quantity of the product in this payment link item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this payment link item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `allow_custom_quantity` (boolean): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable): Minimum quantity allowed if allow_custom_quantity is True - `max_quantity` (integer, nullable): Maximum quantity allowed if allow_custom_quantity is True - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item, if any - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `coupons` (array): List of coupons applied to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `override_payment_methods` (object, nullable): Payment methods override for this payment link - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule used as an override at checkout instead of the default - `installments_start_date` (string (date-time), nullable): Date used to anchor subsequent installment due dates at checkout - `url` (string): Public URL of the payment link for sharing with payers - `amount_collected` (string): Total amount collected from payments (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `documents` (array): Documents attached to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the document - `name` (string): Original filename of the uploaded document - `file_url` (string): Public URL of the uploaded document - `content_type` (string): MIME type of the document - `size_bytes` (integer): Size of the document in bytes - `form` (object, nullable): Custom form attached to the payment link, if any - `id` (string (uuid4)): Unique identifier (UUID) of the form - `name` (string): Name of the form - `definition` (object): Form-builder definition JSON - `amount_in_smallest_unit` (integer): Payment link amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original payment link amount (before discounts) in smallest currency unit. - `amount_collected_in_smallest_unit` (integer): Total amount collected in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create a consumer portal session `POST /api/v2/consumer_portal/sessions` Creates a short-lived, single-use portal session token for a merchant-owned consumer. The returned URL can be used to redirect the consumer or embed the portal in an iframe. ## Request Request body (required) Content type: `application/json` Type: object - `organization_consumer_id` (string (uuid), required) - `subscription_id` (string (uuid), nullable, optional): Optional subscription to deep-link to. Must belong to the same organization_consumer_id. Forwarded to the portal as a URL query param so the SPA can route directly to that subscription on load. - `metered_subscription_id` (string (uuid), nullable, optional): Optional metered subscription to deep-link to. Must belong to the same organization_consumer_id. Forwarded to the portal as a URL query param so the SPA can route directly to that metered subscription on load. ## Responses ### 201: Successful Response Content type: `application/json` Type: object - `id` (string) - `url` (string) - `created_at` (string (date-time)) - `expires_at` (string (date-time)) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Product `POST /api/v2/products` Create a new product with pricing and description. ## Request Request body (required) Content type: `application/json` Type: object - `name` (string, required): Name of the product. (min length 1; max length 160) - `description` (string, nullable, optional): Description of the product. (min length 1; max length 512) - `price` (number | string | null, optional): [DEPRECATED] Price of the product. Use 'prices' array for multi-currency support. - `prices` (array, nullable, optional): Prices for the product in different currencies. At least one price is required. - `currency` (string, required): ISO 4217 currency code (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (number | string, required): Price amount (must be >= 1 for non-metered products; metered products can use up to 12 decimal places) - `is_price_inclusive_of_vat` (boolean, optional): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. (default `true`) - `is_price_exempt_from_vat` (boolean, optional): If True, no VAT applies to this price (default `false`) - `is_one_time` (boolean, optional): Will this product be used only one time in one invoice? (default `false`) - `type` (string, required): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable, optional): Represents the billing cycle interval if product is recurring. Required for cyclic products. For ONE_OFF, value is ignored. (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, optional): The billing cycle multiple if the product is recurring (default `1`; min 1) - `is_price_exempt_from_vat` (boolean, optional): Is the price exempt from VAT? (default `false`) - `is_price_inclusive_of_vat` (boolean, optional): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. (default `true`) - `external_metadata` (object, optional): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable, optional): The accounting system's own item id (e.g. Zoho item_id) for a pre-existing product this product should be linked to instead of creating a new one. (max length 512) ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Product response DTO. This DTO includes both legacy single-price fields and new multi-currency `prices` array for backward compatibility with existing API consumers. Legacy fields (`price`, `currency`, `vat_amount`, etc.) represent the default price and are kept for backward compatibility. New integrations should use the `prices` array. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Create Subscription `POST /api/v2/subscriptions` Create a new subscription with items, coupons, and payment methods. Important: For most use cases, use the Checkout/Payment Link API (`/v2/payment_links`) instead. It generates a payment link that you can embed in your own web page or redirect to. Use Cases: - Create a subscription and manually marking it as paid for reference - Automated subscription creation ## Request Request body (required) Content type: `application/json` Type: object - `notify_consumer` (boolean, optional): Whether to send a notification to the consumer about the subscription's first invoice (default `true`) - `description` (string, nullable, optional): Subscription description or notes (min length 1; max length 512) - `items` (array, required): List of products or services to include in the subscription - `product_id` (string (uuid4), required): UUID of the product to include - `quantity` (integer, required): Quantity of the product - `coupons` (array, nullable, optional): List of coupon UUIDs to apply for discounts on this specific item - `coupons` (array, nullable, optional): List of coupon UUIDs to apply for discounts on subscription invoices - `organization_consumer_id` (string (uuid4), required): UUID of the consumer who will subscribe - `organization_consumer_beneficiaries` (array, nullable, optional): UUID of the beneficiaries to the consumer who will subscribe - `period_start` (string (date-time), required): Start date of the first billing cycle. If no timezone is specified, UTC is assumed. For trial subscriptions, this must be a future date — the trial runs from now until this date. - `until_cycle_number` (integer, nullable, optional): Number of billing cycles before the subscription automatically cancels. If not specified, the subscription continues indefinitely until manually canceled. (min 1) - `override_payment_methods` (object, nullable, optional): Override payment methods for invoices generated by this subscription. Set any field to null to use the organization's global settings for that payment method. - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `currency` (string, optional): Currency code (e.g., SAR, USD). Must match coupon currency for fixed-amount coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`; min length 3; max length 3) - `trial` (boolean, optional): Whether this is a free trial subscription. If true, the trial starts now and billing begins at period_start. (default `false`) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Deactivate Metered Subscription `DELETE /api/v2/metered_subscriptions/{subscription_id}` Deactivate a metered subscription by setting its end time to now. This subscription stops being billable after this exact time. Note: deactivated subscriptions can still have usage recorded; it won't be billed. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier of the metered subscription to deactivate | ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Response for metered subscription. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)) - `product_id` (string (uuid)) - `organization_consumer_id` (string (uuid)) - `organization_id` (string (uuid)) - `starts_at` (string (date-time)) - `ends_at` (string (date-time), nullable) - `created_at` (string (date-time)) - `updated_at` (string (date-time), nullable) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Branch `DELETE /api/v2/branch/{branch_id}` Delete a branch from the organization. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `branch_id` | path | string (uuid) | yes | Unique identifier (UUID) of the branch to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Consumer `DELETE /api/v2/consumers/{consumer_id}` Delete a consumer from the organization. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `consumer_id` | path | string (uuid) | yes | Unique identifier (UUID) of the consumer to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Coupon `DELETE /api/v2/coupons/{coupon_id}` Delete a coupon from the organization. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `coupon_id` | path | string (uuid) | yes | Unique identifier (UUID) of the coupon to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Product `DELETE /api/v2/products/{product_id}` Delete a product from the organization. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Product Price `DELETE /api/v2/products/{product_id}/prices/{price_id}` Archive (soft delete) a product price. Cannot delete the last active price for a product. Each product must have at least one active price. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product | | `price_id` | path | string (uuid) | yes | Unique identifier (UUID) of the price to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Delete Subscription Freeze `DELETE /api/v2/subscriptions/{subscription_id}/freeze/{freeze_id}` Remove a freeze period from a subscription. Deletes the specified freeze period, allowing the subscription to resume normal invoice generation immediately (if the freeze period was active). ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | | `freeze_id` | path | string (uuid) | yes | Unique identifier (UUID) of the freeze period to delete | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Freeze Subscription `POST /api/v2/subscriptions/{subscription_id}/freeze` Freeze a subscription to pause invoice generation for a specific period. During the freeze period, no invoices will be generated for the subscription. The subscription will automatically resume after the freeze period ends. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription to freeze | Request body (required) Content type: `application/json` Type: object - `freeze_start_datetime` (string (date-time), required): Start date and time when the subscription freeze period begins - `freeze_end_datetime` (string (date-time), nullable, optional): End date and time when the subscription freeze period ends. If not provided, the freeze will continue indefinitely until manually removed. - `notes` (string, nullable, optional): Optional notes explaining the reason for the freeze ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get All Branches `GET /api/v2/branch` List the branches where the caller holds ``branches:read``. An organization-wide holder sees every branch. A branch-scoped holder sees those branches. ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `name` (string) - `user_count` (integer, nullable) - `created_at` (string (date-time)) --- ## Get All Consumers `GET /api/v2/consumers` List consumers with pagination, sorting, and optional filters. **Query filters** (all optional; combine as needed): - `search_term` — partial match on name, email, phone, alias, external_id, associated entity name, or associated entity field values **External metadata filters** (optional, combine with other filters): - Use any external metadata key you stored on create/update as a query parameter: `external_metadata.=` - Exact match, case-sensitive. Multiple keys are ANDed. - Example: if a consumer was created with `"external_metadata": {"segment": "enterprise", "tier": "gold"}`, filter with `?external_metadata.segment=enterprise&external_metadata.tier=gold` **Pagination**: `page` (default 1), `limit` (default 10, max 100) **Sorting**: `sort_field` (`name`, `created_at`, `email`, `phone_number`, `external_id`; default `created_at`), `sort_direction` (`asc` or `desc`; default `desc`) **Example**: `/api/v2/consumers?search_term=Acme&external_metadata.segment=enterprise&page=1&limit=20` ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `search_term` | query | string, nullable | no | Free-text search (case-insensitive, partial match). Matches product name and description. Omit to skip text search. Example: `?search_term=premium`. | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `email` (string (email), nullable): Email address of the consumer - `external_id` (string, nullable): External identifier for the consumer - `consumer` (object, nullable): Consumer information - `id` (string (uuid4), nullable): Unique identifier (UUID) of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `iban` (string, nullable): IBAN (International Bank Account Number) of the consumer - `is_deleted` (boolean): Whether the consumer has been deleted - `alias` (string, nullable): Alias of the consumer - `created_at` (string (date-time)): Date and time when the consumer was created - `branch` (object): Branch information for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `comment` (string, nullable): Additional comments or notes about the consumer - `communication_methods` (array): Preferred communication methods for the consumer (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `preferred_language` (string): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`) - `address` (object, nullable): National address (required for business type) - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number (optional for business type) - `commercial_registration` (string, nullable): Commercial registration number (optional for business type) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `beneficiaries` (array): List of beneficiaries - `id` (string (uuid4)): Unique identifier (UUID) of the beneficiary - `name` (string): Name of the beneficiary - `fields` (object): Catalog field values for this associated entity - `fields` (object): Catalog field values for this consumer - `last_invoice_activity` (object, nullable): Information about the most recent invoice activity for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `org_invoice_number` (integer): Organization-specific invoice number - `subcription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if applicable - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Branch By Id `GET /api/v2/branch/{branch_id}` Retrieve detailed information about a specific branch by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `branch_id` | path | string (uuid) | yes | Unique identifier (UUID) of the branch to retrieve | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `name` (string) - `user_count` (integer, nullable) - `created_at` (string (date-time)) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Consumer `GET /api/v2/consumers/{consumer_id}` Retrieve detailed information about a specific consumer by their ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `consumer_id` | path | string (uuid) | yes | Unique identifier (UUID) of the consumer | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `email` (string (email), nullable): Email address of the consumer - `external_id` (string, nullable): External identifier for the consumer - `consumer` (object, nullable): Consumer information - `id` (string (uuid4), nullable): Unique identifier (UUID) of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `iban` (string, nullable): IBAN (International Bank Account Number) of the consumer - `is_deleted` (boolean): Whether the consumer has been deleted - `alias` (string, nullable): Alias of the consumer - `created_at` (string (date-time)): Date and time when the consumer was created - `branch` (object): Branch information for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `comment` (string, nullable): Additional comments or notes about the consumer - `communication_methods` (array): Preferred communication methods for the consumer (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `preferred_language` (string): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`) - `address` (object, nullable): National address (required for business type) - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number (optional for business type) - `commercial_registration` (string, nullable): Commercial registration number (optional for business type) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `beneficiaries` (array): List of beneficiaries - `id` (string (uuid4)): Unique identifier (UUID) of the beneficiary - `name` (string): Name of the beneficiary - `fields` (object): Catalog field values for this associated entity - `fields` (object): Catalog field values for this consumer ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Coupon `GET /api/v2/coupons/{coupon_id}` Retrieve detailed information about a specific coupon including redemption history. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `coupon_id` | path | string (uuid) | yes | Unique identifier (UUID) of the coupon | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `redemptions` (integer): Indicates how many times this coupon has been used. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Invoice `GET /api/v2/invoices/{invoice_id}` Retrieve detailed information about a specific invoice by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `invoice_id` | path | string (uuid) | yes | Unique identifier (UUID) of the invoice | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `invoice_number` (integer): Global unique invoice number - `remaining_amount` (string): Remaining amount to be paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `paid_amount` (string): Total amount already paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `organization_consumer` (object): Consumer information for this invoice - `id` (string (uuid4)) - `name` (string) - `alias` (string, nullable) - `email` (string (email), nullable) - `phone_number` (string (phone), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `consumer_type` (string): (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Address response model. ``address_line_1``/``address_line_2`` mirror ``street``/``district`` for existing clients (the dashboard's customer pages still read them). - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable) - `commercial_registration` (string, nullable) - `consumer` (object, nullable) - `id` (string (uuid4)) - `phone_number` (string (phone), nullable) - `email` (string (email), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `is_deleted` (boolean, nullable) - `communication_methods` (array, nullable): (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `items` (array): List of items included in the invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `product` (object): Product details for this invoice item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `quantity` (integer): Quantity of the product in this invoice item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `unit_price` (string, nullable): Snapshotted unit price at invoice creation (for historical accuracy) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item (for traceability) - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `branch` (object, nullable): Branch information for this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `payments` (array): List of payments associated with this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the payment - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `scheduled_on` (string (date-time)): Scheduled date and time for the payment - `invoice_payment_number` (integer): Payment number within the invoice - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `settled_at` (string (date-time), nullable): Date and time when the payment was settled - `refunded_at` (string (date-time), nullable): Date and time when the payment was refunded - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `pdf_link` (string, nullable): URL to the payment PDF document - `paid_to_account_id` (string (uuid4), nullable): Unique identifier (UUID) of the account the payment was made to - `viban_wallet_transaction_id` (string (uuid4), nullable): The vIBAN wallet DEBIT transaction that paid this payment; absent when none did - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if this invoice is part of a subscription - `subscription` (object, nullable): Subscription details if this invoice is part of a subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. - `payment_methods` (object, nullable): Payment methods available for this invoice - `mada` (boolean, required): Enable Mada payment method - `visa` (boolean, required): Enable Visa payment method - `mastercard` (boolean, required): Enable Mastercard payment method - `amex` (boolean, required): Enable American Express payment method - `bank_transfer` (boolean, required): Enable bank transfer payment method - `installment` (boolean, required): Enable installment payment option - `qurrah` (boolean, optional): Enable Qurrah payment method (default `false`) - `bnpl` (boolean, optional): Enable BNPL (e.g. Tamara) for this invoice (default `false`) - `bnpl_eligibility` (object, nullable): Latest BNPL eligibility for this invoice (provider display name + help message) - `eligible` (boolean) - `provider_name` (string) - `message` (string, nullable) - `recurrence_pattern` (string, nullable): Recurrence pattern for recurring invoices (one of `Hour`, `Day`, `Week`, `Fortnight`, `Month`, `Quarter`, `Half-Year`, `Year`) - `parent_id` (string (uuid4), nullable): Parent invoice ID for recurring invoices - `url` (string): URL to access the invoice - `beneficiaries` (array, nullable): Beneficiaries linked to this invoice - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `adjustments` (array): Credit, debit, and amendment history for this invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `type` (string): (one of `CREDIT`, `DEBIT`, `AMENDMENT`) - `adjustment_reason` (string): (one of `ERROR_IN_PRICING`, `CHANGE_IN_PRODUCT_OR_SERVICE`, `CHANGE_IN_TERM_AND_CONDITIONS`, `OTHER`) - `net_amount_change` (string): (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changed_by` (string): (one of `USER`) - `changed_by_user_id` (string (uuid), nullable) - `products` (array) - `side` (string): (one of `OLD`, `NEW`) - `product_id` (string (uuid)) - `quantity` (integer) - `coupons` (array) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `coupons` (array) - `side` (string): (one of `OLD`, `NEW`) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `total_credited` (string): Sum of credit adjustment amounts (absolute value of negative net changes) (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_debited` (string): Sum of debit adjustment amounts (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_refunded` (string): Sum of payment refunds on this invoice (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `net_received` (string): Sum of paid payment amounts minus total_refunded (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `remaining_amount_in_smallest_unit` (integer): Remaining amount in smallest currency unit. - `paid_amount_in_smallest_unit` (integer): Paid amount in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Metered Subscription `GET /api/v2/metered_subscriptions/{subscription_id}` Retrieve a metered subscription. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier of the metered subscription to retrieve | | `include_usage` | query | boolean | no | Include current usage in the subscription response (default `false`) | ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Response item for listing metered subscriptions. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)) - `product_id` (string (uuid)) - `organization_consumer_id` (string (uuid)) - `organization_id` (string (uuid)) - `starts_at` (string (date-time)) - `ends_at` (string (date-time), nullable) - `created_at` (string (date-time)) - `updated_at` (string (date-time), nullable) - `product` (object): Product details - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `organization_consumer` (object): Organization consumer details - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `current_period_start` (string (date-time)): Start of the current billing period - `current_period_end` (string (date-time)): End of the current billing period - `current_usage` (string, nullable): Current usage amount for the active billing period. Omitted unless include_usage=true. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Payment `GET /api/v2/payments/{payment_id}` Retrieve detailed information about a specific payment by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)): Unique identifier (UUID) of the payment - `organization_id` (string (uuid)): Unique identifier (UUID) of the organization - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `scheduled_on` (string): Scheduled date and time for the payment - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `refunded_at` (string (date-time), nullable): Date and time of the most recent refund - `refund_reason` (string, nullable): Reason for the most recent refund if set (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note for the most recent refund if set - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `latest_pgw_message` (string, nullable): Latest payment gateway message for this payment - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Payment Link `GET /api/v2/payment_links/{payment_link_id}` Retrieve detailed information about a specific payment link by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_link_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment link | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link - `name` (string): Name of the payment link - `description` (string, nullable): Description of the payment link - `amount` (string): Total payment link amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original payment link amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the payment link - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment link (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation; for SAR links or when converted from other currencies. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate from link currency to home currency (SAR) at creation time (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `max_number_of_payments` (integer, nullable): Maximum number of times this payment link can be used - `valid_until` (string (date-time), nullable): UTC datetime after which the payment link is no longer valid - `created_resource_effective_at` (string (date-time), nullable): UTC datetime when the resource created from this payment link becomes effective - `confirmation_message` (string, nullable): Message to display to the payer after successful payment - `recurring_interval` (string, nullable): Billing cycle interval if this payment link creates a subscription (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring payments - `trial_period_days` (integer, nullable): Free trial duration (in days) for subscriptions created from this link. Only meaningful for recurring (subscription) products. When set, each consumer who subscribes via this link gets a free trial of this length, after which the first real billing period begins. Must be between 1 and 365. - `status` (string): Current status of the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the payment link - `organization_consumer_id` (string (uuid4), nullable): Unique identifier (UUID) of the organization consumer if linked to a specific consumer - `deactivate_message` (string, nullable): Message to display when the payment link is deactivated - `custom_fields` (object, nullable): Custom fields schema for collecting additional information - `success_redirect_url` (string, nullable): URL to redirect the payer to after a successful payment - `failure_redirect_url` (string, nullable): URL to redirect the payer to after a failed payment - `custom_metadata` (object, nullable): The key-value metadata dictionary passed during creation. - `contact_information_type` (string, nullable): Type of contact information required for payment collection (one of `PHONE`, `EMAIL`) - `items` (array): List of products included in the payment link - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `quantity` (integer): Quantity of the product in this payment link item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this payment link item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `allow_custom_quantity` (boolean): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable): Minimum quantity allowed if allow_custom_quantity is True - `max_quantity` (integer, nullable): Maximum quantity allowed if allow_custom_quantity is True - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item, if any - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `coupons` (array): List of coupons applied to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `override_payment_methods` (object, nullable): Payment methods override for this payment link - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule used as an override at checkout instead of the default - `installments_start_date` (string (date-time), nullable): Date used to anchor subsequent installment due dates at checkout - `url` (string): Public URL of the payment link for sharing with payers - `amount_collected` (string): Total amount collected from payments (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `documents` (array): Documents attached to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the document - `name` (string): Original filename of the uploaded document - `file_url` (string): Public URL of the uploaded document - `content_type` (string): MIME type of the document - `size_bytes` (integer): Size of the document in bytes - `form` (object, nullable): Custom form attached to the payment link, if any - `id` (string (uuid4)): Unique identifier (UUID) of the form - `name` (string): Name of the form - `definition` (object): Form-builder definition JSON - `amount_in_smallest_unit` (integer): Payment link amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original payment link amount (before discounts) in smallest currency unit. - `amount_collected_in_smallest_unit` (integer): Total amount collected in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Product `GET /api/v2/products/{product_id}` Retrieve detailed information about a specific product by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product | ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Product response DTO. This DTO includes both legacy single-price fields and new multi-currency `prices` array for backward compatibility with existing API consumers. Legacy fields (`price`, `currency`, `vat_amount`, etc.) represent the default price and are kept for backward compatibility. New integrations should use the `prices` array. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get Subscription `GET /api/v2/subscriptions/{subscription_id}` Retrieve detailed information about a specific subscription by its ID. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Get User And Organization Info `GET /api/v2/me` Retrieve information about the authenticated user and their organization. It requires a valid authentication token and can be used to verify API connectivity and retrieve user context. This endpoint returns details about the currently authenticated user and their associated organization. ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Response for /me endpoint. - `user` (object): User information for /me endpoint. - `id` (string (uuid)) - `email` (string) - `first_name` (string) - `last_name` (string) - `en_first_name` (string, nullable) - `en_last_name` (string, nullable) - `created_at` (string (date-time)) - `organization` (object): Organization information for /me endpoint. - `id` (string (uuid)) - `name` (string) - `name_en` (string, nullable) - `sandbox` (boolean) - `created_at` (string (date-time)) - `currency_config` (object): DTO for organization currency configuration. - `home_currency` (string): Settlement/reporting currency. Always SAR for Moyasar settlements. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `default_currency` (string): Default currency for new invoices and products. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `enabled_currencies` (array): List of currencies enabled for billing. Must include at least one. (items one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `["SAR"]`) --- ## List Coupons `GET /api/v2/coupons` List all coupons with pagination, filtering, and sorting options. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `search_term` | query | string, nullable | no | Search by coupon name. | | `active` | query | boolean, nullable | no | Filter by active or inactive coupons. | | `is_percentage` | query | boolean, nullable | no | Filter by percentage-based or fixed-amount coupons. | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `redemptions` (integer): Indicates how many times this coupon has been used. - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Invoices `GET /api/v2/invoices` List all invoices with pagination, filtering, and sorting options. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `include_payments` | query | boolean, nullable | no | | | `payment_link_id` | query | string (uuid), nullable | no | | | `statuses` | query | array, nullable | no | (items one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) | | `payment_statuses` | query | array, nullable | no | Invoice includes payments with the following statuses (items one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) | | `search_term` | query | string, nullable | no | | | `from_date` | query | string (date-time), nullable | no | | | `to_date` | query | string (date-time), nullable | no | | | `due_date_from` | query | string (date-time), nullable | no | Invoice's payment due date from this date onwards | | `due_date_to` | query | string (date-time), nullable | no | Invoice's payment due date to this date or older | | `from_price` | query | number \| string \| null | no | | | `to_price` | query | number \| string \| null | no | | | `organization_consumer_id` | query | string (uuid4), nullable | no | | | `subscription_id` | query | string (uuid4), nullable | no | | | `metered_subscription_id` | query | string (uuid4), nullable | no | | | `currencies` | query | string, nullable | no | Filter by invoice currency codes (OR). E.g. currencies=SAR,USD | | `payments_not_settled` | query | boolean, nullable | no | When true, only include invoices with a SUCCEEDED card/wallet payment (e.g. MADA, Visa). | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `remaining_amount` (string, nullable): Remaining amount to be paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `paid_amount` (string): Total amount already paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `organization_consumer` (object): Consumer information for this invoice - `id` (string (uuid4)) - `name` (string) - `alias` (string, nullable) - `email` (string (email), nullable) - `phone_number` (string (phone), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `consumer_type` (string): (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Address response model. ``address_line_1``/``address_line_2`` mirror ``street``/``district`` for existing clients (the dashboard's customer pages still read them). - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable) - `commercial_registration` (string, nullable) - `consumer` (object, nullable) - `id` (string (uuid4)) - `phone_number` (string (phone), nullable) - `email` (string (email), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `is_deleted` (boolean, nullable) - `communication_methods` (array, nullable): (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `subscription` (object, nullable): Subscription information if this invoice is part of a subscription - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time), nullable): End date and time of the current billing period - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `payments` (array, nullable): List of payments associated with this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the payment - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `scheduled_on` (string (date-time)): Scheduled date and time for the payment - `invoice_payment_number` (integer): Payment number within the invoice - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `settled_at` (string (date-time), nullable): Date and time when the payment was settled - `refunded_at` (string (date-time), nullable): Date and time when the payment was refunded - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `pdf_link` (string, nullable): URL to the payment PDF document - `paid_to_account_id` (string (uuid4), nullable): Unique identifier (UUID) of the account the payment was made to - `viban_wallet_transaction_id` (string (uuid4), nullable): The vIBAN wallet DEBIT transaction that paid this payment; absent when none did - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `total_number_of_payments` (integer): Total number of payments for this invoice - `last_payment_paid_at` (string (date-time), nullable): The date when the last payment was paid - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `remaining_amount_in_smallest_unit` (integer, nullable): Remaining amount in smallest currency unit. - `paid_amount_in_smallest_unit` (integer): Paid amount in smallest currency unit. - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Metered Subscriptions `GET /api/v2/metered_subscriptions` List metered subscriptions. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `include_usage` | query | boolean | no | Include current usage in each subscription response (default `false`) | | `ends_at_lte` | query | string (date-time), nullable | no | End time is on or before this time | | `ends_at_gte` | query | string (date-time), nullable | no | End time is on or after this time; ends_at null is included. | | `starts_at_lte` | query | string (date-time), nullable | no | Start time is on or before this time | | `starts_at_gte` | query | string (date-time), nullable | no | Start time is on or after this time | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)) - `product_id` (string (uuid)) - `organization_consumer_id` (string (uuid)) - `organization_id` (string (uuid)) - `starts_at` (string (date-time)) - `ends_at` (string (date-time), nullable) - `created_at` (string (date-time)) - `updated_at` (string (date-time), nullable) - `product` (object): Product details - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `organization_consumer` (object): Organization consumer details - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `current_period_start` (string (date-time)): Start of the current billing period - `current_period_end` (string (date-time)): End of the current billing period - `current_usage` (string, nullable): Current usage amount for the active billing period. Omitted unless include_usage=true. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Payment Links `GET /api/v2/payment_links` List all payment links with pagination, filtering, and sorting options. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `statuses` | query | array, nullable | no | Filter by subscription status (items one of `INACTIVE`, `ACTIVE`, `COMPLETED`) | | `from_date` | query | string (date-time), nullable | no | datetime is created_at | | `to_date` | query | string (date-time), nullable | no | datetime is created_at | | `from_price` | query | number \| string \| null | no | limit list by min payment link total amount inclusive | | `to_price` | query | number \| string \| null | no | limit list by max payment link total amount inclusive | | `product_ids` | query | array, nullable | no | Product ids that need to be in the list of payment links | | `currencies` | query | string, nullable | no | Filter by currency codes (OR). E.g. currencies=SAR,USD | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link - `name` (string): Name of the payment link - `description` (string, nullable): Description of the payment link - `amount` (string): Total payment link amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original payment link amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the payment link - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment link (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation; for SAR links or when converted from other currencies. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate from link currency to home currency (SAR) at creation time (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `max_number_of_payments` (integer, nullable): Maximum number of times this payment link can be used - `valid_until` (string (date-time), nullable): UTC datetime after which the payment link is no longer valid - `created_resource_effective_at` (string (date-time), nullable): UTC datetime when the resource created from this payment link becomes effective - `confirmation_message` (string, nullable): Message to display to the payer after successful payment - `recurring_interval` (string, nullable): Billing cycle interval if this payment link creates a subscription (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring payments - `trial_period_days` (integer, nullable): Free trial duration (in days) for subscriptions created from this link. Only meaningful for recurring (subscription) products. When set, each consumer who subscribes via this link gets a free trial of this length, after which the first real billing period begins. Must be between 1 and 365. - `status` (string): Current status of the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the payment link - `organization_consumer_id` (string (uuid4), nullable): Unique identifier (UUID) of the organization consumer if linked to a specific consumer - `deactivate_message` (string, nullable): Message to display when the payment link is deactivated - `custom_fields` (object, nullable): Custom fields schema for collecting additional information - `success_redirect_url` (string, nullable): URL to redirect the payer to after a successful payment - `failure_redirect_url` (string, nullable): URL to redirect the payer to after a failed payment - `custom_metadata` (object, nullable): The key-value metadata dictionary passed during creation. - `contact_information_type` (string, nullable): Type of contact information required for payment collection (one of `PHONE`, `EMAIL`) - `items` (array): List of products included in the payment link - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `quantity` (integer): Quantity of the product in this payment link item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this payment link item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `allow_custom_quantity` (boolean): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable): Minimum quantity allowed if allow_custom_quantity is True - `max_quantity` (integer, nullable): Maximum quantity allowed if allow_custom_quantity is True - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item, if any - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `coupons` (array): List of coupons applied to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `override_payment_methods` (object, nullable): Payment methods override for this payment link - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule used as an override at checkout instead of the default - `installments_start_date` (string (date-time), nullable): Date used to anchor subsequent installment due dates at checkout - `url` (string): Public URL of the payment link for sharing with payers - `amount_collected` (string): Total amount collected from payments (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `documents` (array): Documents attached to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the document - `name` (string): Original filename of the uploaded document - `file_url` (string): Public URL of the uploaded document - `content_type` (string): MIME type of the document - `size_bytes` (integer): Size of the document in bytes - `form` (object, nullable): Custom form attached to the payment link, if any - `id` (string (uuid4)): Unique identifier (UUID) of the form - `name` (string): Name of the form - `definition` (object): Form-builder definition JSON - `amount_in_smallest_unit` (integer): Payment link amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original payment link amount (before discounts) in smallest currency unit. - `amount_collected_in_smallest_unit` (integer): Total amount collected in smallest currency unit. - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Payments `GET /api/v2/payments` List all payments with pagination, filtering, and sorting options. Payments can be filtered by invoice IDs, statuses, date ranges, or search terms. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `invoice_id` | query | array, nullable | no | Filter by invoice IDs. Default is None. | | `statuses` | query | array, nullable | no | Filter by payment statuses. Default is None. (items one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) | | `search_term` | query | string, nullable | no | Search term to filter payments. Default is None. | | `from_date` | query | string (date-time), nullable | no | Filter payments from this date. Default is None. | | `to_date` | query | string (date-time), nullable | no | Filter payments up to this date. Default is None. | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)): Unique identifier (UUID) of the payment - `organization_id` (string (uuid)): Unique identifier (UUID) of the organization - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `scheduled_on` (string): Scheduled date and time for the payment - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `refunded_at` (string (date-time), nullable): Date and time of the most recent refund - `refund_reason` (string, nullable): Reason for the most recent refund if set (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note for the most recent refund if set - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `latest_pgw_message` (string, nullable): Latest payment gateway message for this payment - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Products `GET /api/v2/products` List products with pagination, sorting, and optional filters. **Query filters** (all optional; combine as needed): - `search_term` — partial match on product name or description - `active` — `true` for active products only, `false` for inactive only - `type` — product type: `RECURRING`, `ONE_OFF`, or `METERED` (when enabled) - `currency` — only products with an active price in this ISO currency code (e.g. `SAR`) **External metadata filters** (optional, combine with other filters): - Use any external metadata key you stored on create/update as a query parameter: `external_metadata.=` - Exact match, case-sensitive. Multiple keys are ANDed. - Example: if a consumer was created with `"external_metadata": {"segment": "enterprise", "tier": "gold"}`, filter with `?external_metadata.segment=enterprise&external_metadata.tier=gold` **Pagination**: `page` (default 1), `limit` (default 10, max 100) **Sorting**: `sort_field` (`price`, `name`, `created_at`; default `created_at`), `sort_direction` (`asc` or `desc`; default `desc`) **Example**: `/api/v2/products?active=true&type=RECURRING&external_metadata.category=saas¤cy=SAR` ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `search_term` | query | string, nullable | no | Free-text search (case-insensitive, partial match). Matches product name and description. Omit to skip text search. Example: `?search_term=premium`. | | `active` | query | boolean, nullable | no | Filter by product active status. `true` = active only, `false` = inactive only. Omit to return both. Example: `?active=true`. | | `type` | query | string, nullable | no | Filter by product type. Allowed values: `RECURRING`, `ONE_OFF`, `METERED` (when enabled). Example: `?type=RECURRING`. (one of `RECURRING`, `ONE_OFF`, `METERED`) | | `currency` | query | string, nullable | no | Return only products with an active price in this currency. 3-letter ISO 4217 code. Example: `?currency=SAR`. (min length 3; max length 3) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Subscription Freezes `GET /api/v2/subscriptions/{subscription_id}/freeze` List all freeze periods for a specific subscription. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## List Subscriptions `GET /api/v2/subscriptions` List all subscriptions with pagination, filtering, and sorting options. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `statuses` | query | array, nullable | no | Filter by subscription status (items one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) | | `latest_invoice_is_paid` | query | boolean, nullable | no | Filter subscriptions based on if their latest invoice is paid or partially paid | | `from_date` | query | string (date-time), nullable | no | datetime is created_at | | `to_date` | query | string (date-time), nullable | no | datetime is created_at | | `current_period_start_from_date` | query | string (date-time), nullable | no | Filter subscriptions with current_period_start from this date onwards | | `current_period_start_to_date` | query | string (date-time), nullable | no | Filter subscriptions with current_period_start up to this date | | `current_period_end_from_date` | query | string (date-time), nullable | no | Filter subscriptions with current_period_end from this date onwards | | `current_period_end_to_date` | query | string (date-time), nullable | no | Filter subscriptions with current_period_end up to this date | | `from_price` | query | number \| string \| null | no | limit list by min subscription amount inclusive | | `to_price` | query | number \| string \| null | no | limit list by max subscription amount inclusive | | `organization_consumer_id` | query | string (uuid4), nullable | no | filter subscriptions that belongs to organization consumer | | `search_term` | query | string, nullable | no | Serach by product name or description. | | `product_ids` | query | array, nullable | no | Product ids that need to be in the list of subscriptions | | `currencies` | query | string, nullable | no | Filter subscriptions by currency codes (OR). E.g. currencies=SAR,USD | | `page` | query | integer | no | Page number, defaults to 1. (default `1`) | | `limit` | query | integer | no | Size of a page, defaults to 10. Maximum is 100. (default `10`) | | `sort_field` | query | string, nullable | no | Field to sort by, e.g., 'amount', 'scheduled_on' | | `sort_direction` | query | string, nullable | no | Sorting direction ('asc' or 'desc') | ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `data` (array) - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. - `pagination` (object) - `total_count` (integer) - `max_page` (integer) - `current_page` (integer) - `limit` (integer) - `has_next_page` (boolean) - `has_previous_page` (boolean) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Mark Payment As Paid `POST /api/v2/payments/{payment_id}/mark-paid` Manually mark a payment as paid (full or partial). Record a payment received through manual methods (CASH, BANK_TRANSFER, CARD, or QURRAH). **Full:** omit ``amount`` or pass ``amount == payment.amount``. **Partial:** pass ``amount < payment.amount`` with remainder greater than 1 in the payment currency (not allowed while UNDER_REVIEW). - Selected payment amount is reduced and marked SUCCEEDED. - A new PENDING ``SPLIT_REMAINDER`` payment is created for the remainder. - ``invoice.type`` is unchanged (ONE_OFF stays ONE_OFF). - Invoice completes only when every payment is paid. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment to mark as paid | Request body (required) Content type: `application/json` Type: object - `payment_method` (string, required): Manual payment method used. Automated payment methods (e.g., MADA, VISA, MASTERCARD) are not allowed. (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `note` (string, nullable, optional): Optional note or reference number for the payment (e.g., transaction ID, receipt number) (max length 512) - `pos_transaction_id` (string, nullable, optional): Optional transaction/network reference ID. Only allowed when payment_method is CARD. (max length 512) - `amount` (number | string | null, optional): Amount paid now. Omit or set equal to payment.amount for a full mark-as-paid. If less than payment.amount, the payment is split: this amount becomes SUCCEEDED and a new PENDING SPLIT_REMAINDER payment is created for the remainder (remainder must be greater than 1 in the payment currency). Partial mark-as-paid is not allowed while the payment is UNDER_REVIEW. ## Responses ### 200: Successful Response Content type: `application/json` Type: object ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Record Metered Usage `POST /api/v2/metered_subscriptions/record` Record metered usage events in bulk ## Request Request body (required) Content type: `application/json` Type: object. Bulk usage records to record. Each record includes product_id, organization_consumer_id, usage_amount, and a source event ID. - `records` (array, required): List of usage records to record - `product_id` (string (uuid), required): METERED product ID - `organization_consumer_id` (string (uuid), required): Organization consumer ID - `usage_amount` (integer, required): Usage quantity in whole units (max 9999999999) - `source_event_id` (string, required): Stable source event ID used to prevent duplicate usage records ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Refund Payment `POST /api/v2/payments/{payment_id}/refund` Process a refund for a payment. Refunds settle the requested amount or the remaining refundable balance for the selected payment. If that payment is part of a shared Moyasar charge, set ``payment_is_part_of_related_set`` to true to distribute the refund across related payments in invoice order. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment to refund | Request body (required) Content type: `application/json` Type: object - `amount` (number | string | null, optional): Amount to refund. Omit for full remaining refundable balance (payment.amount - sum of existing refunds). Must be > 0 and not exceed remaining. - `refund_reason` (string, required): Reason for the refund (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable, optional): Optional note explaining the refund reason (max length 512) - `payment_is_part_of_related_set` (boolean, optional): Set to true when this payment belongs to a related payment set and the refund should be applied across that set in order. (default `false`) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid)): Unique identifier (UUID) of the payment - `organization_id` (string (uuid)): Unique identifier (UUID) of the organization - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `scheduled_on` (string): Scheduled date and time for the payment - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `refunded_at` (string (date-time), nullable): Date and time of the most recent refund - `refund_reason` (string, nullable): Reason for the most recent refund if set (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note for the most recent refund if set - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `latest_pgw_message` (string, nullable): Latest payment gateway message for this payment - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). ### 400: Multiple payments were paid in a single transaction. Set 'payment_is_part_of_related_set' to true to refund across them. Content type: `application/json` Type: object. Error response for payment refund operations when multiple payments are in a single transaction. - `error` (object, nullable) - `code` (string): (one of `STREAM_ERROR`, `STREAM_UNKNOWN_ERROR`, `PHONE_ALREADY_REGISTERED`, `MFA_VERIFICATION_SESSION_IN_PROGRESS`, `MFA_ATTEMPTS_EXHAUSTED`, `MFA_INVALID`, `MFA_SESSION_EXPIRED`, `MFA_CHANNEL_COOLDOWN`, `RECAPTCHA_INVALID`, `SAUDI_ID_ALREADY_REGISTERED`, `USER_INFO_NOT_VERIFIED`, `COMPANY_NOT_FOUND`, `ORGANIZATION_ALREADY_CREATED`, `SANDBOX_ORGANIZATION_LIMIT_REACHED`, `SANDBOX_ORGANIZATION_CREATION_NOT_ALLOWED`, `ORGANIZATION_DELETION_NOT_SANDBOX`, `ORGANIZATION_DELETION_ONLY_ORGANIZATION`, `ORGANIZATION_DELETION_ONBOARDING_STARTED`, `ORGANIZATION_DELETION_KYB_UNAVAILABLE`, `USER_NOT_REGISTERED`, `OAUTH_ONLY_ACCOUNT`, `CONNECTED_APP_TOKEN_INVALID`, `INVALID_PARAMETERS`, `INVITATION_EXPIRED`, `USER_ALREADY_REGISTERED`, `DISPOSABLE_EMAIL_NOT_ALLOWED`, `PAYMENT_FLOW_NOT_ALLOWED`, `INVOICE_PAYMENT_COUNT_NOT_MATCHED`, `INVOICE_FINALISED`, `INVOICE_NOT_EXPIRABLE`, `INVOICE_EXPIRY_CONFLICT`, `INVOICE_SEND_CONFLICT`, `INVOICE_ROW_LOCKED`, `PAYMENT_SUCCESS_CONFLICT`, `PAYMENT_LATE_CHARGE_EXPIRED`, `PAYMENT_LATE_CHARGE_CANCELED`, `PAYMENT_CLAIM_CONFLICT`, `INVOICE_CANCEL_CONFLICT`, `INVOICE_REACTIVATION_CONFLICT`, `INVOICE_REACTIVATION_BLOCKED`, `PAYMENT_REFUND_CONFLICT`, `PAYMENT_REFUND_NOT_RECORDED`, `PAYMENT_REFUND_NOT_SENT`, `PAYMENT_REFUND_PENDING`, `PAYMENT_REFUND_BUSY`, `PAYMENT_REFUND_BEFORE_SUCCESS`, `INVOICE_INVALID_STATUS`, `INVOICE_TOTAL_MISMATCH_PAYMENT_AMOUNT_SUM`, `INVOICE_CONSENT_CONSUMED`, `INVOICE_CONSENT_EXPIRED`, `INVOICE_EXPIRED`, `PAYMENT_IN_PROGRESS`, `PAYMENT_FINALIZED`, `PAYMEND_UNPAID`, `PAYMENT_REFUNDED_ALREADY`, `PAYMENT_GATEWAY_ONE_REFUND_ONLY`, `PAYMENT_REFUNDED_FAILED`, `PAYMENT_REFUND_INSUFFICIENT_BALANCE`, `PAYMENT_REFUND_WINDOW_EXPIRED`, `POS_TRANSACTION_ID_REQUIRES_CARD`, `INVALID_STATUS`, `ACCOUNT_ONE_DEFAULT_REQUIRED`, `DUPLICATE_CONSUMER`, `DUPLICATE_PAYMENT`, `DUPLICATE_CARD_TOKEN`, `CONSUMER_HAS_ONGOING_INVOICES`, `CONSUMER_HAS_ONGOING_SUBSCRIPTIONS`, `CONSUMER_HAS_ACTIVE_PAYMENT_LINKS`, `MOYASAR_BAD_REQUEST`, `NOTIFICATION_TEMPLATE_DOES_NOT_EXIST`, `FEATURE_DISABLED`, `INSUFFICIENT_FUNDS`, `PAYMENT_GATEWAY_DECLINED`, `MANUAL_INVOICE_CARD_ID`, `ONE_OFF_INVALID_PAYMENT_FLOW`, `ONE_OFF_CARD_ID`, `AUTO_INVOICE_MISSING_CARD_ID`, `MOYASAR_INVALID_CARD_TOKEN`, `MOYASAR_UNAUTHORIZED`, `MOYASAR_FORBIDDEN`, `MOYASAR_NOT_FOUND`, `MOYASAR_METHOD_NOT_ALLOWED`, `MOYASAR_TOO_MANY_REQUESTS`, `MOYASAR_INTERNAL_SERVER_ERROR`, `MOYASAR_SERVICE_UNAVAILABLE`, `MOYASAR_PAYMENT_INFO_MISMATCH`, `MOYASAR_TIMEOUT`, `PAYMENT_REFUND_NOT_PROCESSED`, `PAYMENT_REFUND_OUTCOME_UNKNOWN`, `PDF_LINK_EXISTS`, `BRANCH_NOT_FOUND`, `BRANCH_ACCESS_DENIED`, `PERMISSION_FORBIDDEN`, `PRODUCT_USED_IN_FINALIZED_INVOICE`, `PRODUCT_USED_IN_ACTIVE_PAYMENT_LINK`, `PRODUCT_USED_IN_SCHEDULED_PLAN_CHANGE`, `PRODUCT_BILLING_TERMS_IN_USE`, `RESOURCE_ALREADY_EXISTS`, `COUPON_USED_IN_FINALIZED_INVOICE`, `COUPON_USED_IN_ACTIVE_PAYMENT_LINK`, `CONSUMER_CONTACT_INFO_CHANGE_NOT_ALLOWED`, `WEBHOOK_AUTO_DISABLED`, `INSTALLMENT_OVERLAPPING_MIN_MAX_RANGES`, `INSTALLMENT_GLOBAL_CANNOT_SET_BOUNDS`, `INSTALLMENT_GLOBAL_CANNOT_DISABLE`, `INSTALLMENT_GLOBAL_CANNOT_DELETE`, `INSTALLMENT_CUSTOM_REQUIRES_BOUNDS`, `INSTALLMENT_RULE_MINIMUM_BELOW_SETTINGS_FLOOR`, `INSTALLMENT_OPTIONS_REQUIRED`, `INSTALLMENT_INVALID_PERCENTAGE_WEIGHTS`, `INSTALLMENT_SMALLEST_SHARE_BELOW_MIN`, `INSTALLMENT_SPLIT_AMOUNT_BELOW_MIN`, `INSTALLMENT_INSTALLMENTS_NOT_AVAILABLE`, `INSTALLMENT_SELECTION_NOT_AVAILABLE`, `INSTALLMENT_OVERRIDE_RULE_NOT_AVAILABLE`, `INSTALLMENT_TRIAL_VERIFICATION_NOT_ALLOWED`, `INSTALLMENT_WEIGHTS_REQUIRED`, `INSTALLMENT_SPLIT_AMOUNT_REQUIRED`, `INSTALLMENT_UNABLE_TO_COMPUTE_AMOUNT_SPLITS`, `INSTALLMENT_MAX_INSTALLMENTS_EXCEEDED`, `SANDBOX_CUSTOMER_CREATION_RESTRICTED`, `SANDBOX_INTEGRATION_NOT_ALLOWED`, `ACCOUNTING_OAUTH_STATE_INVALID`, `ACCOUNTING_TEST_CONNECTION_FAILED`, `ACCOUNTING_REFRESH_REQUIRED`, `ACCOUNTING_CONNECTION_INACTIVE`, `ACCOUNTING_OAUTH_EXCHANGE_FAILED`, `ACCOUNTING_ENUM_OPTIONS_MISSING`, `ACCOUNTING_FIELD_OPTIONS_FETCH_FAILED`, `ACCOUNTING_ORG_CONFIG_INCOMPLETE`, `ACCOUNTING_FIELD_INVALID`, `ACCOUNTING_CONFIG_FIELD_NOT_SEEDED`, `ACCOUNTING_BRANCHES_NOT_SUPPORTED`, `ACCOUNTING_BRANCH_PLUGIN_NOT_ENABLED`, `ACCOUNTING_DOCUMENT_SYNC_FAILED`, `ACCOUNTING_ANOTHER_PROVIDER_ACTIVE`, `ACCOUNTING_PARENT_NOT_SYNCED`, `ACCOUNTING_GATEWAY_RECEIVABLES_AUTOMATIC_POSTING_REQUIRED`, `ACCOUNTING_GATEWAY_RECEIVABLES_NO_ACTIVE_PROVIDER`, `ACCOUNTING_GATEWAY_RECEIVABLES_FIELDS_MISSING`, `ACCOUNTING_GATEWAY_RECEIVABLES_FIELD_REQUIRED`, `ACCOUNTING_GATEWAY_RECEIVABLES_RECONNECT_REQUIRED`, `ACCOUNTING_SETTLEMENT_CONNECTION_INACTIVE`, `ACCOUNTING_SETTLEMENT_CURRENCY_MISMATCH`, `ACCOUNTING_SETTLEMENT_TOTALS_MISMATCH`, `ACCOUNTING_SETTLEMENT_UNSUPPORTED_LINE_TYPE`, `ACCOUNTING_SETTLEMENT_PERIOD_LOCKED`, `SETTLEMENT_BALANCE_UNAVAILABLE`, `INVOICE_SYNCED_TO_ANOTHER_ACC_PLATFORM`, `ZATCA_ONBOARDING_IN_PROGRESS`, `ZATCA_ALREADY_ONBOARDED`, `ZATCA_CUSTOMER_ADDRESS_INCOMPLETE`, `ZATCA_NOT_ELIGIBLE`, `DISCOUNT_RULE_PRODUCT_ALREADY_ASSIGNED`, `DISCOUNT_RULE_COUPON_PERCENTAGE_TOO_HIGH`, `DISCOUNT_RULE_COUPON_FIXED_AMOUNT_INVALID`, `DISCOUNT_RULE_COUPON_CURRENCY_UNAVAILABLE_FOR_PRODUCT`, `DISCOUNT_RULE_COUPON_INELIGIBLE_AFTER_UPDATE`, `DISCOUNT_RULE_APPLICABLE_COUPON_MISSING`, `VIBAN_NOT_ENABLED`, `VIBAN_CONFIG_REQUIRED`, `VIBAN_ALREADY_EXISTS`, `VIBAN_PROVIDER_ERROR`, `VIBAN_INSUFFICIENT_BALANCE`, `VIBAN_PAYMENT_NOT_ELIGIBLE`, `VIBAN_IDEMPOTENCY_KEY_REUSED`, `VIBAN_CUSTOMER_HAS_BALANCE`) - `message` (string) - `additional_info` (string, nullable) - `payment_ids` (array): List of payment IDs that were paid in the same transaction - `total_amount` (string): Total amount of all payments in the transaction (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Uncancel Subscription `PUT /api/v2/subscriptions/{subscription_id}/uncancel` Withdraw a pending cancellation so the subscription continues after the current billing period. Only **ACTIVE** subscriptions are accepted. If the subscription is not scheduled to be cancelled, the request succeeds as a no-op. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | ## Responses ### 200: Successful Response Content type: `application/json` Type: any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Branch `PUT /api/v2/branch/{branch_id}` Update branch information. If a branch with the same name already exists, returns an error. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `branch_id` | path | string (uuid) | yes | Unique identifier (UUID) of the branch to update | Request body (required) Content type: `application/json` Type: object - `name` (string, required): New name for the branch. Must be unique within the organization. (min length 1; max length 100) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `name` (string) - `user_count` (integer, nullable) - `created_at` (string (date-time)) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Consumer `PUT /api/v2/consumers/{consumer_id}` Update consumer information such as contact details or payment methods. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `consumer_id` | path | string (uuid) | yes | Unique identifier (UUID) of the consumer to update | Request body (required) Content type: `application/json` Type: object. Consumer update model with all fields optional. - `name` (string, nullable): Consumer name (max length 512) - `phone_number` (string (phone), nullable): Phone number - `email` (string (email), nullable): Email address - `external_id` (string, nullable): External ID (max length 512) - `iban` (string, nullable): IBAN (max length 34) - `alias` (string, nullable): Alias (max length 512) - `comment` (string, nullable): Comment (max length 512) - `preferred_language` (string, nullable): Preferred language (one of `AR`, `EN`) - `communication_methods` (array, nullable): Communication methods (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `consumer_type` (string, nullable): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`) - `address` (object, nullable): Address (required for business type) - `street` (string, required): Street name (alias: address_line_1) - `district` (string, nullable, optional): District (alias: address_line_2) - `building_number` (string, nullable, optional): Building number (4 digits for Saudi addresses) (max length 255) - `city` (string, required): City - `postal_code` (string, nullable, optional): Postal code - `country` (string, required): Country - `vat_number` (string, nullable): VAT number (optional for business type) (max length 64) - `commercial_registration` (string, nullable): Commercial registration number (optional for business type) (max length 512) - `beneficiaries` (array, nullable): List of beneficiaries (optional) - `id` (string (uuid), nullable, optional): Beneficiary to update - `name` (string, required): New name for the beneficiary - `fields` (object, nullable, optional): When set, replaces all catalog field values for this associated entity - `delete` (boolean, optional): Whether to delete the beneficiary (default `false`) - `fields` (object, nullable): Full replacement of the consumer's catalog field values; omit to leave unchanged - `external_metadata` (object): Overwrites existing external metadata entirely. To merge values, send the full desired external metadata object. ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `email` (string (email), nullable): Email address of the consumer - `external_id` (string, nullable): External identifier for the consumer - `consumer` (object, nullable): Consumer information - `id` (string (uuid4), nullable): Unique identifier (UUID) of the consumer - `phone_number` (string (phone), nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `iban` (string, nullable): IBAN (International Bank Account Number) of the consumer - `is_deleted` (boolean): Whether the consumer has been deleted - `alias` (string, nullable): Alias of the consumer - `created_at` (string (date-time)): Date and time when the consumer was created - `branch` (object): Branch information for this consumer - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `comment` (string, nullable): Additional comments or notes about the consumer - `communication_methods` (array): Preferred communication methods for the consumer (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `preferred_language` (string): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type: individual or business (one of `INDIVIDUAL`, `BUSINESS`) - `address` (object, nullable): National address (required for business type) - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number (optional for business type) - `commercial_registration` (string, nullable): Commercial registration number (optional for business type) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `beneficiaries` (array): List of beneficiaries - `id` (string (uuid4)): Unique identifier (UUID) of the beneficiary - `name` (string): Name of the beneficiary - `fields` (object): Catalog field values for this associated entity - `fields` (object): Catalog field values for this consumer ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Coupon `PUT /api/v2/coupons/{coupon_id}` Update coupon details such as discount amount or active status. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `coupon_id` | path | string (uuid) | yes | Unique identifier (UUID) of the coupon to update | Request body (required) Content type: `application/json` Type: object - `name` (string, nullable): Updated name of the coupon. (min length 1; max length 80) - `discount_value` (number | string | null): Updated discount value (either percentage or fixed). - `currency` (string, nullable): Currency code for fixed-amount coupons. Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean, nullable): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean, nullable): Whether the coupon should be active or inactive. ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Invoice In Place `PATCH /api/v2/invoices/{invoice_id}/inplace` Partially update specific invoice fields in-place. This endpoint allows updating only the fields specified in the request. Use for quick changes such as updating the description or scheduled date. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `invoice_id` | path | string (uuid) | yes | | Request body (required) Content type: `application/json` Type: object. DTO for partial in-place updates to invoice fields. This DTO allows updating specific fields of an invoice without requiring all fields. Only the fields provided will be updated. All fields are optional. Note: This endpoint performs in-place updates. Use this for simple field updates. - `scheduled_on` (string (date-time), nullable): The scheduled payment date for the invoice. After this date, the invoice will be considered overdue. Cannot be earlier than the current scheduled date. - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule to use as an override for this invoice. If null, the default rule is used. Cannot be changed once the invoice is split into installments. - `installments_start_date` (string (date-time), nullable): When the invoice is split into installments, this date anchors the due dates of subsequent installments. Example: for a monthly plan split into 3 installments, with scheduled_on set to Jan 1: If installments_start_date is null, the subsequent installments are due on Feb 1 and Mar 1. If installments_start_date is Feb 4, they are due on Feb 4 and Mar 4. - `expires_at` (string (date-time), nullable): Optional expiry for one-off invoices, with a timezone (e.g. 2026-12-01T10:00:00Z). Omit to keep the current value; send null to remove it. Can only be changed while the invoice is CREATED. Must be in the future and after scheduled_on. - `description` (string, nullable): Description of the invoice. Provides additional context or details about the invoice. Must be between 1 and 512 characters if provided. (min length 1; max length 512) - `accounting_external_id` (string, nullable): The accounting system's own record id for a pre-existing invoice. Only takes effect when set for the first time (was previously empty); later changes are ignored here. (max length 512) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `invoice_number` (integer): Global unique invoice number - `remaining_amount` (string): Remaining amount to be paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `paid_amount` (string): Total amount already paid (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `organization_consumer` (object): Consumer information for this invoice - `id` (string (uuid4)) - `name` (string) - `alias` (string, nullable) - `email` (string (email), nullable) - `phone_number` (string (phone), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `consumer_type` (string): (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Address response model. ``address_line_1``/``address_line_2`` mirror ``street``/``district`` for existing clients (the dashboard's customer pages still read them). - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable) - `commercial_registration` (string, nullable) - `consumer` (object, nullable) - `id` (string (uuid4)) - `phone_number` (string (phone), nullable) - `email` (string (email), nullable) - `preferred_language` (string): (one of `AR`, `EN`) - `is_deleted` (boolean, nullable) - `communication_methods` (array, nullable): (items one of `WHATSAPP`, `EMAIL`, `SMS`) - `items` (array): List of items included in the invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `product` (object): Product details for this invoice item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `quantity` (integer): Quantity of the product in this invoice item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `unit_price` (string, nullable): Snapshotted unit price at invoice creation (for historical accuracy) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item (for traceability) - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `branch` (object, nullable): Branch information for this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the branch - `name` (string): Name of the branch - `payments` (array): List of payments associated with this invoice - `id` (string (uuid4)): Unique identifier (UUID) of the payment - `amount` (string): Payment amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `scheduled_on` (string (date-time)): Scheduled date and time for the payment - `invoice_payment_number` (integer): Payment number within the invoice - `type` (string): Type of payment (one of `INITIAL`, `INSTALLMENT`, `SPLIT_PREPAID`, `SPLIT_REMAINDER`) - `payment_method` (string, nullable): Payment method used (one of `MADA`, `MASTERCARD`, `VISA`, `APPLE_PAY`, `SAMSUNG_PAY`, `AMEX`, `CASH`, `PGW_CARD_UNSPECIFIED`, `BANK_TRANSFER`, `CARD`, `QURRAH`, `BNPL`) - `pos_transaction_id` (string, nullable): Transaction/network reference ID for card/POS payments - `current_status` (string): Current status of the payment (one of `PENDING`, `PROCESSING`, `FAILED_INITIATION`, `SUCCEEDED`, `FAILED`, `CANCELED`, `UNDER_REVIEW`, `EXPIRED`, `SETTLED`, `REFUNDED`, `PARTIALLY_REFUNDED`) - `payed_at` (string (date-time), nullable): Date and time when the payment was completed - `settled_at` (string (date-time), nullable): Date and time when the payment was settled - `refunded_at` (string (date-time), nullable): Date and time when the payment was refunded - `amount_refunded` (string): Sum of this payment's REFUNDED refunds; PENDING and CANCELED refunds don't count (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `refunds` (array): Refund history for this payment - `id` (string (uuid)): Unique identifier of the refund row - `amount_refunded` (string): Amount refunded in this refund (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `status` (string): REFUNDED once the money went back. PENDING while the payment gateway hasn't executed it yet (MyFatoorah), CANCELED if it didn't: neither counts in amount_refunded. (one of `PENDING`, `REFUNDED`, `CANCELED`; default `"REFUNDED"`) - `refunded_at` (string (date-time), nullable): When the money went back; empty unless REFUNDED - `refund_reason` (string, nullable): Reason for the refund if applicable (one of `REQUESTED_BY_CUSTOMER`, `DUPLICATE`, `FRAUDULENT`, `OTHER`) - `refund_note` (string, nullable): Note explaining the refund if applicable - `pdf_link` (string, nullable): URL to the payment PDF document - `paid_to_account_id` (string (uuid4), nullable): Unique identifier (UUID) of the account the payment was made to - `viban_wallet_transaction_id` (string (uuid4), nullable): The vIBAN wallet DEBIT transaction that paid this payment; absent when none did - `amount_in_smallest_unit` (integer): Payment amount in smallest currency unit (e.g. halala for SAR). - `subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the subscription if this invoice is part of a subscription - `subscription` (object, nullable): Subscription details if this invoice is part of a subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. - `payment_methods` (object, nullable): Payment methods available for this invoice - `mada` (boolean, required): Enable Mada payment method - `visa` (boolean, required): Enable Visa payment method - `mastercard` (boolean, required): Enable Mastercard payment method - `amex` (boolean, required): Enable American Express payment method - `bank_transfer` (boolean, required): Enable bank transfer payment method - `installment` (boolean, required): Enable installment payment option - `qurrah` (boolean, optional): Enable Qurrah payment method (default `false`) - `bnpl` (boolean, optional): Enable BNPL (e.g. Tamara) for this invoice (default `false`) - `bnpl_eligibility` (object, nullable): Latest BNPL eligibility for this invoice (provider display name + help message) - `eligible` (boolean) - `provider_name` (string) - `message` (string, nullable) - `recurrence_pattern` (string, nullable): Recurrence pattern for recurring invoices (one of `Hour`, `Day`, `Week`, `Fortnight`, `Month`, `Quarter`, `Half-Year`, `Year`) - `parent_id` (string (uuid4), nullable): Parent invoice ID for recurring invoices - `url` (string): URL to access the invoice - `beneficiaries` (array, nullable): Beneficiaries linked to this invoice - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `adjustments` (array): Credit, debit, and amendment history for this invoice - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `type` (string): (one of `CREDIT`, `DEBIT`, `AMENDMENT`) - `adjustment_reason` (string): (one of `ERROR_IN_PRICING`, `CHANGE_IN_PRODUCT_OR_SERVICE`, `CHANGE_IN_TERM_AND_CONDITIONS`, `OTHER`) - `net_amount_change` (string): (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changed_by` (string): (one of `USER`) - `changed_by_user_id` (string (uuid), nullable) - `products` (array) - `side` (string): (one of `OLD`, `NEW`) - `product_id` (string (uuid)) - `quantity` (integer) - `coupons` (array) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `coupons` (array) - `side` (string): (one of `OLD`, `NEW`) - `coupon_id` (string (uuid)) - `order` (integer): (default `0`) - `total_credited` (string): Sum of credit adjustment amounts (absolute value of negative net changes) (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_debited` (string): Sum of debit adjustment amounts (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_refunded` (string): Sum of payment refunds on this invoice (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `net_received` (string): Sum of paid payment amounts minus total_refunded (default `"0"`; pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `remaining_amount_in_smallest_unit` (integer): Remaining amount in smallest currency unit. - `paid_amount_in_smallest_unit` (integer): Paid amount in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Payment Link Coupons `PATCH /api/v2/payment_links/{payment_link_id}/coupons` Update link-level and item-level coupons on a payment link. Recomputes totals. New checkouts use the updated coupons; payments already in progress are unchanged. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_link_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment link to update | Request body (required) Content type: `application/json` Type: object - `coupons` (array): Link-level coupons (replaces existing). Omit or [] clears link-level coupons. - `items` (array): Item-level coupons per item listed; omitted items assume no coupons. - `payment_link_item_id` (string (uuid4), required): Id of an existing payment link item - `coupons` (array, optional): Item-level coupons for this item (replaces existing). Omit or [] clears item-level coupons on this item. ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link - `name` (string): Name of the payment link - `description` (string, nullable): Description of the payment link - `amount` (string): Total payment link amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original payment link amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the payment link - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment link (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation; for SAR links or when converted from other currencies. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate from link currency to home currency (SAR) at creation time (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `max_number_of_payments` (integer, nullable): Maximum number of times this payment link can be used - `valid_until` (string (date-time), nullable): UTC datetime after which the payment link is no longer valid - `created_resource_effective_at` (string (date-time), nullable): UTC datetime when the resource created from this payment link becomes effective - `confirmation_message` (string, nullable): Message to display to the payer after successful payment - `recurring_interval` (string, nullable): Billing cycle interval if this payment link creates a subscription (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring payments - `trial_period_days` (integer, nullable): Free trial duration (in days) for subscriptions created from this link. Only meaningful for recurring (subscription) products. When set, each consumer who subscribes via this link gets a free trial of this length, after which the first real billing period begins. Must be between 1 and 365. - `status` (string): Current status of the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the payment link - `organization_consumer_id` (string (uuid4), nullable): Unique identifier (UUID) of the organization consumer if linked to a specific consumer - `deactivate_message` (string, nullable): Message to display when the payment link is deactivated - `custom_fields` (object, nullable): Custom fields schema for collecting additional information - `success_redirect_url` (string, nullable): URL to redirect the payer to after a successful payment - `failure_redirect_url` (string, nullable): URL to redirect the payer to after a failed payment - `custom_metadata` (object, nullable): The key-value metadata dictionary passed during creation. - `contact_information_type` (string, nullable): Type of contact information required for payment collection (one of `PHONE`, `EMAIL`) - `items` (array): List of products included in the payment link - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `quantity` (integer): Quantity of the product in this payment link item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this payment link item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `allow_custom_quantity` (boolean): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable): Minimum quantity allowed if allow_custom_quantity is True - `max_quantity` (integer, nullable): Maximum quantity allowed if allow_custom_quantity is True - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item, if any - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `coupons` (array): List of coupons applied to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `override_payment_methods` (object, nullable): Payment methods override for this payment link - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule used as an override at checkout instead of the default - `installments_start_date` (string (date-time), nullable): Date used to anchor subsequent installment due dates at checkout - `url` (string): Public URL of the payment link for sharing with payers - `amount_collected` (string): Total amount collected from payments (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `documents` (array): Documents attached to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the document - `name` (string): Original filename of the uploaded document - `file_url` (string): Public URL of the uploaded document - `content_type` (string): MIME type of the document - `size_bytes` (integer): Size of the document in bytes - `form` (object, nullable): Custom form attached to the payment link, if any - `id` (string (uuid4)): Unique identifier (UUID) of the form - `name` (string): Name of the form - `definition` (object): Form-builder definition JSON - `amount_in_smallest_unit` (integer): Payment link amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original payment link amount (before discounts) in smallest currency unit. - `amount_collected_in_smallest_unit` (integer): Total amount collected in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Payment Link Status `PATCH /api/v2/payment_links/{payment_link_id}/status` Update the status of a payment link. Allows activating or deactivating a payment link. When deactivated, the link will no longer accept new payments. Existing payments in progress are not affected. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `payment_link_id` | path | string (uuid) | yes | Unique identifier (UUID) of the payment link to update | Request body (required) Content type: `application/json` Type: object - `status` (string, required): New status for the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `deactivate_message` (string, nullable, optional): Optional message to display when the payment link is deactivated (max length 512) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link - `name` (string): Name of the payment link - `description` (string, nullable): Description of the payment link - `amount` (string): Total payment link amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original payment link amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the payment link - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the payment link (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation; for SAR links or when converted from other currencies. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate from link currency to home currency (SAR) at creation time (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `max_number_of_payments` (integer, nullable): Maximum number of times this payment link can be used - `valid_until` (string (date-time), nullable): UTC datetime after which the payment link is no longer valid - `created_resource_effective_at` (string (date-time), nullable): UTC datetime when the resource created from this payment link becomes effective - `confirmation_message` (string, nullable): Message to display to the payer after successful payment - `recurring_interval` (string, nullable): Billing cycle interval if this payment link creates a subscription (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring payments - `trial_period_days` (integer, nullable): Free trial duration (in days) for subscriptions created from this link. Only meaningful for recurring (subscription) products. When set, each consumer who subscribes via this link gets a free trial of this length, after which the first real billing period begins. Must be between 1 and 365. - `status` (string): Current status of the payment link (one of `INACTIVE`, `ACTIVE`, `COMPLETED`) - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the payment link - `organization_consumer_id` (string (uuid4), nullable): Unique identifier (UUID) of the organization consumer if linked to a specific consumer - `deactivate_message` (string, nullable): Message to display when the payment link is deactivated - `custom_fields` (object, nullable): Custom fields schema for collecting additional information - `success_redirect_url` (string, nullable): URL to redirect the payer to after a successful payment - `failure_redirect_url` (string, nullable): URL to redirect the payer to after a failed payment - `custom_metadata` (object, nullable): The key-value metadata dictionary passed during creation. - `contact_information_type` (string, nullable): Type of contact information required for payment collection (one of `PHONE`, `EMAIL`) - `items` (array): List of products included in the payment link - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the payment link item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `quantity` (integer): Quantity of the product in this payment link item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this payment link item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `allow_custom_quantity` (boolean): Whether customers can select custom quantity for this item (default `false`) - `min_quantity` (integer, nullable): Minimum quantity allowed if allow_custom_quantity is True - `max_quantity` (integer, nullable): Maximum quantity allowed if allow_custom_quantity is True - `currency` (string): Currency code for this item (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `product_price_id` (string (uuid4), nullable): Reference to the ProductPrice used for this item, if any - `original_amount_in_smallest_unit` (integer): Original item amount in smallest currency unit. - `discounted_amount_in_smallest_unit` (integer): Discounted item amount in smallest currency unit. - `coupons` (array): List of coupons applied to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the coupon - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the coupon. (min length 1; max length 80) - `discount_value` (string): Discount value of the coupon (either percentage or fixed). (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g. SAR). Null for percentage coupons. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `is_percentage` (boolean): True if the discount is a percentage, False if it is a fixed amount. - `is_active` (boolean): Indicates if the coupon is currently active. - `override_payment_methods` (object, nullable): Payment methods override for this payment link - `visa` (boolean): visa is enabled (default `false`) - `mastercard` (boolean): mastercard is enabled (default `false`) - `amex` (boolean): amex is enabled (default `false`) - `bank_transfer` (boolean): bank_transfer is enabled (default `false`) - `installment` (boolean): installment is enabled (default `false`) - `bnpl` (boolean): Enable BNPL (e.g. Tamara) for this payment link (default `false`) - `installment_rule_override_id` (string (uuid4), nullable): ID of the installment rule used as an override at checkout instead of the default - `installments_start_date` (string (date-time), nullable): Date used to anchor subsequent installment due dates at checkout - `url` (string): Public URL of the payment link for sharing with payers - `amount_collected` (string): Total amount collected from payments (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `documents` (array): Documents attached to the payment link - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the document - `name` (string): Original filename of the uploaded document - `file_url` (string): Public URL of the uploaded document - `content_type` (string): MIME type of the document - `size_bytes` (integer): Size of the document in bytes - `form` (object, nullable): Custom form attached to the payment link, if any - `id` (string (uuid4)): Unique identifier (UUID) of the form - `name` (string): Name of the form - `definition` (object): Form-builder definition JSON - `amount_in_smallest_unit` (integer): Payment link amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original payment link amount (before discounts) in smallest currency unit. - `amount_collected_in_smallest_unit` (integer): Total amount collected in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Product `PUT /api/v2/products/{product_id}` Update product details such as name, price, or description. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product to update | Request body (required) Content type: `application/json` Type: object - `name` (string, nullable): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (min length 1; max length 512) - `price` (number | string | null): [DEPRECATED] Price of the product. Use 'prices' array for multi-currency support. - `prices` (array, nullable): Prices for the product in different currencies. - `currency` (string, required): ISO 4217 currency code (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (number | string, required): Price amount (must be >= 1 for non-metered products; metered products can use up to 12 decimal places) - `is_price_inclusive_of_vat` (boolean, optional): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. (default `true`) - `is_price_exempt_from_vat` (boolean, optional): If True, no VAT applies to this price (default `false`) - `is_active` (boolean, nullable): Whether the product is active. If `true`, the product won't be available for purchase anymore. Existing customers will still have access to the product details in the invoice, and subscriptions will continue normally. - `type` (string, nullable): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring. Required for cyclic products (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): The billing cycle multiple if the product is recurring (min 1) - `is_price_exempt_from_vat` (boolean): Is the price exempt from VAT? (default `false`) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. (default `true`) - `external_metadata` (object): Overwrites existing external metadata entirely. To merge values, send the full desired external metadata object. - `accounting_external_id` (string, nullable): The accounting system's own item id for a pre-existing product. Only takes effect when set for the first time (was previously empty); later changes are ignored. (max length 512) ## Responses ### 200: Successful Response Content type: `application/json` Type: object. Product response DTO. This DTO includes both legacy single-price fields and new multi-currency `prices` array for backward compatibility with existing API consumers. Legacy fields (`price`, `currency`, `vat_amount`, etc.) represent the default price and are kept for backward compatibility. New integrations should use the `prices` array. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Product Price `PUT /api/v2/products/{product_id}/prices/{price_id}` Update a product price. This follows an immutable pricing pattern: the old price is archived and a new price is created with the updated values. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `product_id` | path | string (uuid) | yes | Unique identifier (UUID) of the product | | `price_id` | path | string (uuid) | yes | Unique identifier (UUID) of the price to update | Request body (required) Content type: `application/json` Type: object. DTO for updating a product price. - `amount` (number | string | null): Price amount (must be >= 1 for non-metered products; metered products can use up to 12 decimal places) - `is_price_inclusive_of_vat` (boolean, nullable): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean, nullable): If True, no VAT applies to this price ## Responses ### 200: Successful Response Content type: `application/json` Type: object. DTO for product price response. - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)) - `organization_id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `amount_in_smallest_unit` (integer): Price amount in smallest currency unit (e.g. halala for SAR). ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Subscription `PUT /api/v2/subscriptions/{subscription_id}` Update subscription items, coupons, billing interval, description, auto-cancel cycles, or payment methods. Updatable fields: - **Items** (products and quantities) — deferred to the next cycle. - **Subscription-level coupons** — same deferral as items. - **Recurring interval / interval count** (e.g. monthly ↔ yearly) — deferred to the next cycle. - **Description** — applied immediately. - **Until cycle number** (auto-cancel) — applied immediately. - **Payment method overrides** — applied immediately. Any change to items, coupons, or interval is recorded as a *pending change* that takes effect at ``current_period_end``. The response carries a ``pending_change`` block describing the deferred change, including a ``next_invoice_preview`` and the per-line diff. If the next-cycle invoice has already been generated and is unpaid, it is automatically cancelled and re-issued with the new amount. To change anything else (e.g. the consumer / payer), cancel the subscription and create a new one. Use ``DELETE /pending-change`` to revert a previously scheduled change before it takes effect. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription to update | Request body (required) Content type: `application/json` Type: object - `description` (string, nullable, optional): Description of the subscription. (max length 512) - `items` (array, required): products to purchaseIf you want to keep existing items, include them in the list. - `product_id` (string (uuid4), required): UUID of the product to include - `quantity` (integer, required): Quantity of the product - `coupons` (array, nullable, optional): List of coupon UUIDs to apply for discounts on this specific item - `coupons` (array, required): coupons to apply to the subscription for discounts.If you want to keep existing coupons, include them in the list. - `until_cycle_number` (integer, nullable, optional): Number of billing cycles the subscription should run before it auto-cancels. If set to the current cycle, cancellation is scheduled at period end. If set to null, subscription will continue indefinitely until manually canceled. (min 1) - `override_payment_methods` (object, nullable, optional): overriden payment methods for generated invoices for the payer - sending 'null' for any value means we should follow organization global settings for that method - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `recurring_interval` (string, nullable, optional): Optional new billing interval. If omitted, the current interval is preserved. Use this to flip monthly <-> yearly without re-checkout. Interval changes always take effect at the next cycle (deferred). (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer, nullable, optional): Optional new interval multiplier. Defaults to the current value if omitted. Same deferral behavior as ``recurring_interval``. (min 1) ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `description` (string, nullable): Description of the subscription - `amount` (string): Total subscription amount after discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original subscription amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the subscription - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `remaining_days` (integer): Number of days remaining in the current billing period - `currency` (string): Currency code for the subscription (e.g., SAR, USD) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `home_currency_amount` (string, nullable): Amount in home currency (SAR) at creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at subscription creation (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `recurring_interval` (string): Billing cycle interval (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `recurring_interval_count` (integer): Number of intervals per billing cycle (e.g., 2 for bi-monthly) - `status` (string): Current status of the subscription (one of `INACTIVE`, `ACTIVE`, `EXPIRED`, `CANCELED`, `FROZEN`, `TRIALING`, `TRIAL_PENDING`) - `current_period_start` (string (date-time)): Start date and time of the current billing period - `current_period_end` (string (date-time)): End date and time of the current billing period - `current_cycle_number` (integer): Current cycle number of the subscription - `cancel_at_period_end` (boolean): Whether the subscription will be canceled at the end of the current period - `cancel_at_cycle_number` (integer, nullable): Cycle number at which the subscription will be automatically canceled - `started_at` (string (date-time), nullable): Date and time when the subscription started - `ended_at` (string (date-time), nullable): Date and time when the subscription ended - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the subscription - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `latest_invoice_id` (string (uuid4), nullable): Unique identifier (UUID) of the most recent invoice for this subscription - `trial_period_days` (integer, nullable): Number of days for the free trial period - `trial_end` (string (date-time), nullable): Date and time when the trial period ends - `organization_consumer` (object, nullable): Consumer information for this subscription - `id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `name` (string): Name of the consumer - `alias` (string, nullable): Alias of the consumer - `email` (string, nullable): Email address of the consumer - `phone_number` (string, nullable): Phone number of the consumer - `preferred_language` (string, nullable): Preferred language of the consumer (one of `AR`, `EN`) - `consumer_type` (string): Consumer type (individual or business) (one of `INDIVIDUAL`, `BUSINESS`; default `"INDIVIDUAL"`) - `address` (object, nullable): Business address for business consumers - `street` (string): Street name - `district` (string, nullable): District - `building_number` (string, nullable): Building number - `city` (string): City - `postal_code` (string, nullable): Postal code - `country` (string): Country - `address_line_1` (string): Same as street - `address_line_2` (string, nullable): Same as district - `vat_number` (string, nullable): VAT number for business consumers - `commercial_registration` (string, nullable): Commercial registration for business consumers - `items` (array, nullable): List of items included in the subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the subscription item - `product_id` (string (uuid4)): Unique identifier (UUID) of the product - `subscription_id` (string (uuid4)): Unique identifier (UUID) of the subscription - `quantity` (integer): Quantity of the product in this subscription item - `original_amount` (string): Original amount before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Amount after discounts are applied (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to this item - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `product` (object): Product details for this subscription item - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the product - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `name` (string): Name of the product. (min length 1; max length 160) - `description` (string, nullable): Description of the product. (max length 512) - `type` (string): the type of product: one off or recurring (one of `RECURRING`, `ONE_OFF`, `METERED`) - `recurring_interval` (string, nullable): Represents the billing cycle interval if product is recurring (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer): The billing cycle multiple if the product is recurring - `price` (string): Total price including VAT (default currency). - `currency` (string): Default price currency of the product. (one of `AED`, `AFN`, `ALL`, `AMD`, `AOA`, `ARS`, `AUD`, `AWG`, `AZN`, `BAM`, `BBD`, `BDT`, `BHD`, `BIF`, `BMD`, `BND`, `BOB`, `BOV`, `BRL`, `BSD`, `BTN`, `BWP`, `BYN`, `BZD`, `CAD`, `CDF`, `CHE`, `CHF`, `CHW`, `CLF`, `CLP`, `CNY`, `COP`, `COU`, `CRC`, `CUP`, `CVE`, `CZK`, `DJF`, `DKK`, `DOP`, `DZD`, `EGP`, `ERN`, `ETB`, `EUR`, `FJD`, `FKP`, `GBP`, `GEL`, `GHS`, `GIP`, `GMD`, `GNF`, `GTQ`, `GYD`, `HKD`, `HNL`, `HTG`, `HUF`, `IDR`, `ILS`, `INR`, `IQD`, `IRR`, `ISK`, `JMD`, `JOD`, `JPY`, `KES`, `KGS`, `KHR`, `KMF`, `KPW`, `KRW`, `KWD`, `KYD`, `KZT`, `LAK`, `LBP`, `LKR`, `LRD`, `LSL`, `LYD`, `MAD`, `MDL`, `MGA`, `MKD`, `MMK`, `MNT`, `MOP`, `MRU`, `MUR`, `MVR`, `MWK`, `MXN`, `MXV`, `MYR`, `MZN`, `NAD`, `NGN`, `NIO`, `NOK`, `NPR`, `NZD`, `OMR`, `PAB`, `PEN`, `PGK`, `PHP`, `PKR`, `PLN`, `PYG`, `QAR`, `RON`, `RSD`, `RUB`, `RWF`, `SAR`, `SBD`, `SCR`, `SDG`, `SEK`, `SGD`, `SHP`, `SLE`, `SOS`, `SRD`, `SSP`, `STN`, `SVC`, `SYP`, `SZL`, `THB`, `TJS`, `TMT`, `TND`, `TOP`, `TRY`, `TTD`, `TWD`, `TZS`, `UAH`, `UGX`, `USD`, `USN`, `UYI`, `UYU`, `UYW`, `UZS`, `VED`, `VES`, `VND`, `VUV`, `WST`, `XAD`, `XAF`, `XCD`, `XCG`, `XOF`, `XPF`, `XSU`, `XUA`, `YER`, `ZAR`, `ZMW`, `ZWG`; default `"SAR"`; min length 3; max length 3) - `is_price_exempt_from_vat` (boolean): Is the default price exempt from VAT? - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `price_excluding_vat` (string): [DEPRECATED] Default price excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount for default price. VAT will be calculated on invoice. - `prices` (array): All active prices for this product across different currencies. - `id` (string (uuid4)) - `currency` (string): ISO 4217 currency codes supported by Moyasar. Includes all currencies supported by Moyasar payment gateway. (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `amount` (string) - `is_active` (boolean) - `is_price_inclusive_of_vat` (boolean): [DEPRECATED] This field will be removed; non-exempt prices will be assumed inclusive. - `is_price_exempt_from_vat` (boolean) - `price_excluding_vat` (string): [DEPRECATED] Net amount excluding VAT. VAT will be calculated on invoice. - `vat_amount` (string): [DEPRECATED] VAT amount. VAT will be calculated on invoice. - `is_active` (boolean): Can this product be used in invoices or subscriptions? - `is_one_time` (boolean): Shows if the product was created to be used once, and not to be added to product cataloge - `is_used_in_finalized_invoice` (boolean): Is the product used in a finalized invoice? (default `false`) - `external_metadata` (object): Flat key-value external metadata. Keys: ASCII letters/digits/underscore/hyphen, start with a letter, max 64 chars. Values: strings up to 128 chars in any language (no nested objects). - `accounting_external_id` (string, nullable): The accounting system's own item id this product is linked to, if any - `latest_invoice` (object, nullable): Most recent invoice generated for this subscription - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid4)): Unique identifier (UUID) of the invoice - `payment_link_id` (string (uuid4), nullable): Unique identifier (UUID) of the payment link if invoice was created from one - `metered_subscription_id` (string (uuid4), nullable): Unique identifier (UUID) of the metered subscription billed by this invoice - `user_id` (string (uuid4)): Unique identifier (UUID) of the user who created the invoice - `organization_id` (string (uuid4)): Unique identifier (UUID) of the organization - `organization_consumer_id` (string (uuid4)): Unique identifier (UUID) of the organization consumer - `account_id` (string (uuid4)): Unique identifier (UUID) of the account - `branch_id` (string (uuid4)): Unique identifier (UUID) of the branch - `org_invoice_number` (integer): Organization-specific invoice number - `description` (string, nullable): Description of the invoice - `total_amount` (string): Total invoice amount after discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `original_amount` (string): Original invoice amount before discounts (in invoice currency) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `item_level_discounted_amount` (string): Total amount discounted at the item level (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_vat_amount` (string, nullable): Total VAT amount calculated from products (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_price_excluding_vat` (string, nullable): Total price excluding VAT (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `coupon_calculation_metadata` (object, nullable): Metadata about how coupons were applied to the invoice - `coupons` (array): List of coupons applied and their calculation details - `coupon_id` (string): Unique identifier of the coupon - `name` (string): Name of the coupon - `is_percentage` (boolean): Whether the discount is a percentage or fixed amount - `discount_value` (string): Discount value (percentage or fixed amount) (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string, nullable): Currency code for fixed-amount coupons (e.g., SAR, USD). Null for percentage coupons. - `order` (integer): Order in which the coupon was applied - `amount_before_discount` (string): Amount before applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_amount` (string): Discount amount applied by this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `amount_after_discount` (string): Amount after applying this coupon (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency code for the invoice (e.g., SAR, USD, EUR) (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`; default `"SAR"`) - `home_currency_amount` (string, nullable): Total in home currency (SAR) for reporting. Equals total_amount for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `home_currency_amount_actual` (string, nullable): Actual settled amount in home currency (SAR) after payment processing. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `exchange_rate_at_creation` (string, nullable): Exchange rate used at invoice creation time (for audit). 1 for SAR invoices. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `consumer_message` (string, nullable): Message to display to the consumer - `status` (string): Current status of the invoice (one of `DRAFT`, `CREATED`, `SENT`, `ACCEPTED`, `REJECTED`, `COMPLETED`, `CANCELED`, `EXPIRED`) - `payment_method` (string): Payment method for the invoice (one of `OPENBANKING`, `PAYMENTGATEWAY`) - `allowed_payment_flow` (string): Allowed payment flow for the invoice (one of `ALL`, `AUTO`, `MANUAL`) - `current_payment_flow` (string, nullable): Current payment flow being used (one of `ALL`, `AUTO`, `MANUAL`) - `period_start` (string (date-time), nullable): Start date and time of the billing period - `period_end` (string (date-time), nullable): End date and time of the billing period - `recurring_interval` (string, nullable): Billing cycle interval if this is a recurring invoice (one of `WEEK`, `MONTH`, `SEMESTER`, `YEAR`) - `recurring_interval_count` (integer, nullable): Number of intervals per billing cycle for recurring invoices - `type` (string, nullable): Type of invoice (one of `ONE_OFF`, `ONE_OFF_FUTURE`, `RECURRING`, `INSTALLMENTS`, `PRORATION`) - `no_of_payments` (integer, nullable): Number of payment rows on the invoice (updated when payments are added or split) - `installments_start_date` (string (date-time), nullable): Anchor date for installment plan after payment - `expires_at` (string (date-time), nullable): When this invoice expires if it is still unpaid (UTC); null means it never expires - `installment_rule_override_id` (string (uuid4), nullable): Override installment rule offered on this invoice instead of the amount-based default - `accounting_external_id` (string, nullable): The accounting system's own record id this invoice is reconciled against, if any - `total_amount_in_smallest_unit` (integer): Total invoice amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original invoice amount (before discounts) in smallest currency unit. - `latest_freeze` (object, nullable): Most recent freeze period applied to this subscription - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) - `override_payment_methods` (object, nullable): Payment methods override for this subscription - `visa` (boolean, nullable): override visa from global settings - `mastercard` (boolean, nullable): override mastercard from global settings - `amex` (boolean, nullable): override amex from global settings - `bank_transfer` (boolean, nullable): override bank_transfer from global settings - `installment` (boolean, nullable): override installment from global settings - `qurrah` (boolean, nullable): override qurrah from global settings - `subscription_auto_renewal` (boolean, nullable): Override organization's subscription auto renewal setting. If True, subscription will auto-renew at the end of each period. If False, subscription will be canceled at the end of the current period. If None (default), uses organization's subscription_auto_renewal setting. - `pending_change` (object, nullable): A scheduled deferred change that will be applied at current_period_end, if any - `id` (string (uuid4)): Pending change identifier - `effective_at` (string (date-time)): When this change will take effect (subscription period end) - `invoice_was_reissued` (boolean): True if the next-cycle invoice had to be cancelled and recreated to reflect this change - `target_items` (array): Items the subscription will have after the change is applied - `product_id` (string (uuid4)): Product UUID - `product_name` (string): Product display name - `quantity` (integer): Quantity that will be billed under the new plan - `original_amount` (string): Per-item original amount in subscription currency (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discounted_amount` (string): Per-item amount after item-level discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `target_subscription_coupon_ids` (array): Subscription-level coupons that will be active after the change - `target_recurring_interval` (string): Billing interval after the change (one of `WEEK`, `MONTH`, `QUARTER`, `YEAR`) - `target_recurring_interval_count` (integer): Billing interval multiplier after the change - `target_amount` (string): Total amount per cycle under the new plan (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of all monetary fields here (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `current_amount` (string): Subscription's current per-cycle amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount` (string): target_amount - current_amount (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `delta_amount_per_month` (string, nullable): target_amount - current_amount, normalised to a monthly rate. Useful for displaying interval flips in like-for-like terms. (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `changes` (array): Human-renderable, server-computed list of changes - `kind` (string): Classification of this diff entry (one of `PRODUCT_ADDED`, `PRODUCT_REMOVED`, `PRODUCT_REPLACED`, `QUANTITY_DECREASED`, `QUANTITY_INCREASED`, `COUPON_ADDED`, `COUPON_REMOVED`, `INTERVAL_CHANGED`) - `label` (string): Pre-formatted, locale-neutral label suitable for display - `product_id` (string (uuid4), nullable): Affected product, if applicable - `from_value` (string, nullable): Pre-change value, if applicable - `to_value` (string, nullable): Post-change value, if applicable - `next_invoice_preview` (object): Fully precomputed next invoice that will be billed under the new plan - `period_start` (string (date-time)): Period start of the next invoice - `period_end` (string (date-time)): Period end of the next invoice - `issue_at` (string (date-time)): When the next invoice will be issued (notification time) - `due_at` (string (date-time)): When the next invoice will be due - `subtotal` (string): Subtotal before discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `discount_total` (string): Sum of all discounts (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `total_amount` (string): Total amount payable (pattern `^(?!^[-+.]*$)[+-]?0*\d*\.?\d*$`) - `currency` (string): Currency of the next invoice (one of `SAR`, `USD`, `EUR`, `GBP`, `AED`, `BHD`, `KWD`, `OMR`, `QAR`) - `beneficiaries` (array, nullable): Beneficiaries linked to this subscription - `beneficiary_id` (string (uuid)) - `beneficiary_name` (string) - `fields` (object): Catalog field values for this associated entity - `amount_in_smallest_unit` (integer): Subscription amount in smallest currency unit (e.g. halala for SAR). - `original_amount_in_smallest_unit` (integer): Original subscription amount (before discounts) in smallest currency unit. ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Update Subscription Freeze `PUT /api/v2/subscriptions/{subscription_id}/freeze/{freeze_id}` Update an existing subscription freeze period. Allows modifying the start and end dates of a freeze period. The subscription will remain frozen during the updated period. ## Request | Name | In | Type | Required | Description | | --- | --- | --- | --- | --- | | `subscription_id` | path | string (uuid) | yes | Unique identifier (UUID) of the subscription | | `freeze_id` | path | string (uuid) | yes | Unique identifier (UUID) of the freeze period to update | Request body (required) Content type: `application/json` Type: object - `freeze_start_datetime` (string (date-time), required): freeze_start_datetime is always provided even if it dont change - `freeze_end_datetime` (string (date-time), nullable, required): freeze_end_datetime is optional, if provided, it must be greater than freeze_start_datetime - `notes` (string, nullable, optional): Optional notes explaining the reason for the freeze ## Responses ### 200: Successful Response Content type: `application/json` Type: object - `created_by_type` (string): How the object was created: USER (dashboard), API_KEY, CONNECTED_APP, CUSTOMER (payer), ADMIN_PANEL, OPS, SYSTEM (Stream itself), or UNKNOWN (created before this was tracked). (one of `USER`, `API_KEY`, `CONNECTED_APP`, `CUSTOMER`, `ADMIN_PANEL`, `OPS`, `SYSTEM`, `UNKNOWN`; default `"UNKNOWN"`) - `created_by_id` (string (uuid), nullable): Unique identifier (UUID) of the user who created the object. For API_KEY it is the key's owner, for CONNECTED_APP the user who connected the app; a placeholder user for CUSTOMER, ADMIN_PANEL, OPS and SYSTEM; null when UNKNOWN. - `created_at` (string (date-time)): Creation timestamp of the object. - `updated_at` (string (date-time), nullable): Last modification timestamp of the object. - `id` (string (uuid)) - `organization_id` (string (uuid)) - `freeze_start_datetime` (string (date-time)) - `freeze_end_datetime` (string (date-time), nullable) - `notes` (string, nullable) - `subscription_id` (string (uuid)) - `invoice_id` (string (uuid)) - `duration` (integer, nullable) ### 422: Validation Error Content type: `application/json` Type: object - `detail` (array) - `loc` (array) - `msg` (string) - `type` (string) - `input` (any) - `ctx` (object) --- ## Express SDK For the complete Express SDK documentation, please visit our GitHub repository: **[📦 @streamsdk/express on GitHub →](https://github.com/streampayments/streamsdk-express)** ## Quick Links - **[Installation & Quick Start](https://github.com/streampayments/streamsdk-express#installation)** - **[API Documentation](https://github.com/streampayments/streamsdk-express#api-documentation)** - **[Code Examples](https://github.com/streampayments/streamsdk-express/tree/main/examples)** - **[Demo Application](https://github.com/streampayments/stream-express-sdk-demo)** - **[npm Package](https://www.npmjs.com/package/@streamsdk/express)** ## Overview The Stream Express SDK provides a clean, declarative way to integrate Stream payments into your Express.js applications. Built on top of [@streamsdk/typescript](https://www.npmjs.com/package/@streamsdk/typescript), it offers drop-in handlers for checkout flows and webhook processing. **Key Benefits:** - 🚀 **Simple Integration** - Add payment processing in minutes - 🔒 **Type-Safe** - Full TypeScript support with type definitions - 🎯 **Event-Driven** - Clean event handlers for webhook processing - 🔄 **Flexible** - Supports guest and authenticated checkout flows - 📦 **Lightweight** - Minimal dependencies (~7KB) - 🔗 **Auto-Updates** - Inherits stream-sdk updates automatically ## Installation ```bash npm install @streamsdk/express ``` ## Quick Example ```typescript const app = express(); app.use(express.json()); // Payment link handler app.get("/checkout", Checkout({ apiKey: process.env.STREAM_API_KEY!, successUrl: "https://myapp.com/success", returnUrl: "https://myapp.com/cancel", })); // Webhook handler with events app.post("/webhooks/stream", Webhooks({ apiKey: process.env.STREAM_API_KEY!, onPaymentSucceeded: async (data) => { console.log("Payment succeeded:", data); // Update your database, send confirmation emails, etc. }, onPaymentFailed: async (data) => { console.log("Payment failed:", data); }, onInvoiceCreated: async (data) => { console.log("Invoice created:", data); }, })); app.listen(3000); ``` For complete documentation, examples, and API reference, visit the [GitHub repository](https://github.com/streampayments/streamsdk-express). ## Demo Application Want to see it in action? Clone and run the **[Express SDK demo repository](https://github.com/streampayments/stream-express-sdk-demo)** locally for a quick working example. ## Related SDKs - **[TypeScript SDK](/sdks/typescript)** - Core SDK for Node.js/TypeScript - **[API Reference](/api/v2-payment-links-create)** - REST API documentation - **[Webhooks Guide](/webhooks)** - Webhook event reference --- ## TypeScript SDK For the complete TypeScript SDK documentation, please visit our GitHub repository: **[📦 @streamsdk/typescript on GitHub →](https://github.com/streampayments/streamsdk-typescript)** ## Quick Links - **[Installation & Quick Start](https://github.com/streampayments/streamsdk-typescript#installation)** - **[API Documentation](https://github.com/streampayments/streamsdk-typescript#api-documentation)** - **[Code Examples](https://github.com/streampayments/streamsdk-typescript/tree/main/examples)** - **[npm Package](https://www.npmjs.com/package/@streamsdk/typescript)** ## Overview The Stream TypeScript SDK provides a complete Node.js/TypeScript interface for: - 🔐 Secure API Key authentication - 👥 Customer (Consumer) management - 📦 Product catalog management - 💳 Payment link creation - 🔄 Subscription handling - 🧾 Invoice generation - 🎟️ Coupon & discount management ## Installation ```bash npm install @streamsdk/typescript ``` ## Quick Example ```typescript const client = StreamSDK.init(process.env.STREAM_API_KEY!); const result = await client.createSimplePaymentLink({ name: "Monthly Subscription", amount: 99.99, consumer: { email: "customer@example.com", name: "Ahmad Ali", phone: "+966501234567", }, product: { name: "Premium Plan", price: 99.99, }, successRedirectUrl: "https://yourapp.com/success", failureRedirectUrl: "https://yourapp.com/failure", }); console.log("Payment URL:", result.paymentUrl); ``` For complete documentation, examples, and API reference, visit the [GitHub repository](https://github.com/streampayments/streamsdk-typescript). ## Related SDKs - **[Express.js SDK](/sdks/express)** - Framework adapter for Express.js applications - **[API Reference](/api/v2-payment-links-create)** - REST API documentation