> ## Documentation Index
> Fetch the complete documentation index at: https://developers-docs.easyorders.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Debit the wallet

> **Scope:** none. Every app can call it.

Takes `amount` from your app's wallet on the store, for usage your
app charges as it sees fit. The merchant reads `description` in the
wallet's transactions, after your app's name.

- `amount` is a string of US dollars, more than zero, with up to 6
  decimals (`"0.05"`, `"0.000001"`).
- The `Idempotency-Key` header is required. The same key again
  answers `201` with the first debit and `Idempotent-Replayed: true`,
  and takes nothing, even if the wallet, the subscription or your
  app changed since. The same key with another `amount` or
  `description` answers `422 idempotency_key_reused`.
- The balance never goes below zero: a wallet that does not cover the
  amount answers `402 insufficient_balance`.
- A new debit is refused while the subscription is `suspended`
  (`402 payment_required`).
- Your app can never add to the wallet: only the merchant tops it up.




## OpenAPI

````yaml /openapi.json post /billing/wallet/debits
openapi: 3.1.0
info:
  title: EasyOrders Admin API
  version: v1
  summary: Read and write a merchant's store data from your app.
  description: |
    The EasyOrders Admin API lets an installed app work with one merchant's
    store: its orders, shipping settings and shipping areas, within the
    scopes the merchant approved.

    - Every request needs an access token (`Authorization: Bearer eo_at_...`)
      from the OAuth flow. A token works on one store only.
    - Request and response bodies are JSON. Unknown fields and query
      parameters are refused.
    - Errors share one shape: `{"error": {"code", "message", "details"}}`.
    - `v1` is stable: new fields and endpoints are added to it; a breaking
      change ships as a new version.
  contact:
    name: EasyOrders developers
    url: https://easyorders.eg
servers:
  - url: https://api.easy-orders.net/api/partners-apps/v1
    description: Production
security:
  - accessToken: []
tags:
  - name: Article categories
    description: >-
      The categories of the store's blog, which articles name in their
      `category_ids`.
  - name: Articles
    description: The articles of the store's blog, with HTML content, tags and categories.
  - name: Billing
    description: >-
      Your app's plan subscription and usage wallet on the store, and debiting
      the wallet by usage.
  - name: Categories
    description: The store's product categories and subcategories.
  - name: Checkout fields
    description: >-
      The fields of the store's checkout form, their labels, order, and whether
      they show and are required.
  - name: Coupons
    description: >-
      The store's coupons, by code or automatic, and the products, variants and
      categories they apply to.
  - name: Labels
    description: >-
      Your app's short colored words on orders and products, shown in the
      merchant's orders and products tables.
  - name: Missed orders
    description: >-
      Checkouts the shopper started and did not finish, to follow up and
      recover.
  - name: Orders
    description: The store's orders, their status, payment status and notes.
  - name: Pages
    description: >-
      The store's pages, such as About us or the return policy, with HTML
      content.
  - name: Products
    description: The store's products, their options, variants and stock.
  - name: Reviews
    description: >-
      The reviews of the store's products, and which of them the product page
      shows.
  - name: Shipping
    description: The store's shipping settings and shipping areas (governorates).
  - name: Store
    description: >-
      The store the access token belongs to, its addresses, currency, language
      and plan.
paths:
  /billing/wallet/debits:
    post:
      tags:
        - Billing
      summary: Debit the wallet
      description: |
        **Scope:** none. Every app can call it.

        Takes `amount` from your app's wallet on the store, for usage your
        app charges as it sees fit. The merchant reads `description` in the
        wallet's transactions, after your app's name.

        - `amount` is a string of US dollars, more than zero, with up to 6
          decimals (`"0.05"`, `"0.000001"`).
        - The `Idempotency-Key` header is required. The same key again
          answers `201` with the first debit and `Idempotent-Replayed: true`,
          and takes nothing, even if the wallet, the subscription or your
          app changed since. The same key with another `amount` or
          `description` answers `422 idempotency_key_reused`.
        - The balance never goes below zero: a wallet that does not cover the
          amount answers `402 insufficient_balance`.
        - A new debit is refused while the subscription is `suspended`
          (`402 payment_required`).
        - Your app can never add to the wallet: only the merchant tops it up.
      operationId: createBillingWalletDebit
      parameters:
        - $ref: '#/components/parameters/BillingDebitIdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - amount
                - description
              additionalProperties: false
              properties:
                amount:
                  $ref: '#/components/schemas/BillingAmount'
                description:
                  type: string
                  minLength: 1
                  maxLength: 200
                  description: |
                    One line the merchant reads after your app's name, with at
                    least one character that shows. No `<`, and no control or
                    invisible characters.
            example:
              amount: '0.05'
              description: SMS for order 1043
      responses:
        '201':
          description: >-
            The debit. On a replay, the first debit, with `Idempotent-Replayed:
            true`.
          headers:
            Idempotent-Replayed:
              description: >-
                `true` when the key was used before and this is the first debit
                again.
              schema:
                type: string
                enum:
                  - 'true'
          content:
            application/json:
              schema:
                type: object
                required:
                  - debit
                properties:
                  debit:
                    $ref: '#/components/schemas/BillingDebit'
              example:
                debit:
                  id: 7c1d2e3f-4a5b-4c6d-8e7f-9a0b1c2d3e4f
                  amount: '0.05'
                  balance_after: '19.95'
                  description: 'خصم من محفظة تطبيق SMS Notify: SMS for order 1043'
                  created_at: '2026-12-03T10:00:00Z'
        '400':
          $ref: '#/components/responses/InvalidRequest'
        '401':
          $ref: '#/components/responses/Unauthenticated'
        '402':
          description: |
            `insufficient_balance`: the wallet does not cover the amount; or
            `payment_required`: the subscription is suspended.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: insufficient_balance
                  message: The app's wallet balance is not enough
        '409':
          description: |
            `wallet_not_enabled`: your app has no usage wallet; or
            `app_suspended`: your app is suspended and is being removed from
            the store.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: wallet_not_enabled
                  message: The app has no usage wallet
        '422':
          description: |
            `validation_failed` (a missing `Idempotency-Key` too, with the
            rule `printable_ascii`), or `idempotency_key_reused`: the key was
            used for a debit with another amount or description.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              example:
                error:
                  code: idempotency_key_reused
                  message: This Idempotency-Key was used with a different request
        '429':
          $ref: '#/components/responses/RateLimited'
      x-codeSamples:
        - lang: bash
          label: cURL
          source: >-
            curl -X POST
            "https://api.easy-orders.net/api/partners-apps/v1/billing/wallet/debits"
            \
              -H "Authorization: Bearer $EASYORDERS_ACCESS_TOKEN" \
              -H "Idempotency-Key: sms-order-1043" \
              -H "Content-Type: application/json" \
              -d '{
              "amount": "0.05",
              "description": "SMS for order 1043"
            }'
        - lang: typescript
          label: TypeScript
          source: >-
            const response = await
            fetch('https://api.easy-orders.net/api/partners-apps/v1/billing/wallet/debits',
            {
              method: 'POST',
              headers: {
                Authorization: `Bearer ${process.env.EASYORDERS_ACCESS_TOKEN}`,
                'Idempotency-Key': 'sms-order-1043',
                'Content-Type': 'application/json',
              },
              body: JSON.stringify({
                amount: '0.05',
                description: 'SMS for order 1043',
              }),
            })


            const json = await response.json()

            if (!response.ok) {
              throw new Error(`${json.error.code}: ${json.error.message}`)
            }

            const { debit } = json
        - lang: go
          label: Go
          source: "package main\n\nimport (\n\t\"bytes\"\n\t\"encoding/json\"\n\t\"fmt\"\n\t\"net/http\"\n\t\"os\"\n)\n\nfunc main() {\n\tbody := []byte(`{\n\t  \"amount\": \"0.05\",\n\t  \"description\": \"SMS for order 1043\"\n\t}`)\n\n\treq, err := http.NewRequest(\"POST\", \"https://api.easy-orders.net/api/partners-apps/v1/billing/wallet/debits\", bytes.NewReader(body))\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treq.Header.Set(\"Authorization\", \"Bearer \"+os.Getenv(\"EASYORDERS_ACCESS_TOKEN\"))\n\treq.Header.Set(\"Idempotency-Key\", \"sms-order-1043\")\n\treq.Header.Set(\"Content-Type\", \"application/json\")\n\n\tres, err := http.DefaultClient.Do(req)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tdefer res.Body.Close()\n\n\tvar answer map[string]any\n\tif err := json.NewDecoder(res.Body).Decode(&answer); err != nil {\n\t\tpanic(err)\n\t}\n\tif res.StatusCode >= 300 {\n\t\tpanic(fmt.Sprint(res.Status, answer[\"error\"]))\n\t}\n\tfmt.Println(answer[\"debit\"])\n}"
        - lang: php
          label: PHP
          source: >-
            <?php


            $ch =
            curl_init('https://api.easy-orders.net/api/partners-apps/v1/billing/wallet/debits');

            curl_setopt_array($ch, [
                CURLOPT_CUSTOMREQUEST => 'POST',
                CURLOPT_RETURNTRANSFER => true,
                CURLOPT_HTTPHEADER => [
                    'Authorization: Bearer ' . getenv('EASYORDERS_ACCESS_TOKEN'),
                    'Idempotency-Key: sms-order-1043',
                    'Content-Type: application/json',
                ],
                CURLOPT_POSTFIELDS => json_encode([
                    'amount' => '0.05',
                    'description' => 'SMS for order 1043',
                ]),
            ]);


            $answer = json_decode(curl_exec($ch), true);

            $status = curl_getinfo($ch, CURLINFO_RESPONSE_CODE);

            curl_close($ch);


            if ($status >= 300) {
                throw new RuntimeException($answer['error']['code'] . ': ' . $answer['error']['message']);
            }

            $debit = $answer['debit'];
        - lang: python
          label: Python
          source: |-
            import os

            import requests

            response = requests.post(
                "https://api.easy-orders.net/api/partners-apps/v1/billing/wallet/debits",
                headers={
                    "Authorization": f"Bearer {os.environ['EASYORDERS_ACCESS_TOKEN']}",
                    "Idempotency-Key": "sms-order-1043",
                },
                json={
                    "amount": "0.05",
                    "description": "SMS for order 1043",
                },
                timeout=30,
            )
            answer = response.json()
            if not response.ok:
                raise RuntimeError(f"{answer['error']['code']}: {answer['error']['message']}")
            debit = answer["debit"]
components:
  parameters:
    BillingDebitIdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: |
        A unique key for this debit (up to 255 printable ASCII characters),
        from your own record. It is kept with the debit, so sending it again
        later answers the first debit instead of taking twice.
      schema:
        type: string
        minLength: 1
        maxLength: 255
  schemas:
    BillingAmount:
      type: string
      pattern: ^[0-9]+(\.[0-9]{1,6})?$
      description: US dollars as a string, more than zero, with up to 6 decimals.
    BillingDebit:
      type: object
      properties:
        id:
          type: string
          format: uuid
        amount:
          type: string
          description: US dollars.
        balance_after:
          type: string
          description: The wallet's balance right after this debit.
        description:
          type: string
          description: >-
            What the merchant reads, in Arabic, naming your app first, then your
            `description`.
        created_at:
          type: string
          format: date-time
    Error:
      type: object
      required:
        - error
      properties:
        error:
          type: object
          required:
            - code
            - message
          properties:
            code:
              type: string
              description: A stable, snake_case code. Branch on it, not on the message.
            message:
              type: string
              description: A human-readable explanation. It may change.
            details:
              description: More about the error, shaped per code.
  responses:
    InvalidRequest:
      description: >-
        The body is not a JSON object, or has a field of the wrong type or an
        unknown field.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: invalid_request
              message: 'Invalid JSON body: unknown field'
    Unauthenticated:
      description: The access token is missing, invalid or expired.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: unauthenticated
              message: Missing or invalid access token
    RateLimited:
      description: More than 600 requests in a minute from your app on this store.
      headers:
        Retry-After:
          $ref: '#/components/headers/Retry-After'
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          example:
            error:
              code: too_many_requests
              message: Rate limit exceeded
  headers:
    Retry-After:
      description: Seconds to wait before retrying.
      schema:
        type: integer
  securitySchemes:
    accessToken:
      type: http
      scheme: bearer
      description: >
        An access token from the OAuth flow (`eo_at_...`). It lasts one hour;

        refresh it with the refresh token. See
        [Authentication](/authentication).

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.