> For the complete documentation index, see [llms.txt](https://docs.jgopay.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.jgopay.com/english/create-withdrawal.md).

# Create Withdrawal

Initiate a withdrawal (payout) to a Malaysian bank account or e-wallet.

## Endpoint

```http
POST /payment/withdraw
Authorization: Bearer <access_token>
Content-Type: application/json
```

## Request Body

| Field            | Type   | Required | Description                                                                                                       |
| ---------------- | ------ | -------- | ----------------------------------------------------------------------------------------------------------------- |
| `amount`         | number | Yes      | Withdrawal amount (up to 2 decimal places, **50.00 – 50,000.00 MYR**)                                             |
| `currency`       | string | Yes      | ISO 4217 currency code (`MYR`)                                                                                    |
| `reference_id`   | string | Yes      | Your unique withdrawal reference (max 100 chars, **alphanumeric only**)                                           |
| `bank_code`      | string | Yes      | Bank or e-wallet code (see [Bank Codes](/english/bank-codes.md))                                                  |
| `account_number` | string | Yes      | Beneficiary bank account number                                                                                   |
| `account_name`   | string | Yes      | Beneficiary account holder name                                                                                   |
| `method`         | string | Yes      | Always `BANK` for MYR withdrawals                                                                                 |
| `phone_number`   | string | No       | Beneficiary phone number (required by some gateways)                                                              |
| `callback_url`   | string | No       | Callback URL for withdrawal result notification. Falls back to merchant default                                   |
| `metadata`       | object | No       | Custom key-value data stored with the withdrawal. **Not** returned in callbacks — use `reference_id` to correlate |

> **Security:** `callback_url` must use HTTPS (`https://`) in production. HTTP URLs are rejected with HTTP 422. This prevents interception of callback payloads containing withdrawal status and account details.

## Field Validation

| Field            | Rule                                    | Notes                                                |
| ---------------- | --------------------------------------- | ---------------------------------------------------- |
| `amount`         | 50.00 – 50,000.00 MYR, up to 2 decimals | Outside this range is rejected with `INVALID_AMOUNT` |
| `reference_id`   | **Alphanumeric only** (a-z, A-Z, 0-9)   | No spaces, hyphens, or special characters            |
| `account_number` | String, 1-50 characters                 | Bank account or e-wallet number                      |
| `account_name`   | String, 1-100 characters                | Must match the account holder                        |
| `bank_code`      | Must be a valid MYR code                | See [Bank Codes](/english/bank-codes.md)             |

## Request Example

```json
{
  "amount": 500.00,
  "currency": "MYR",
  "reference_id": "WD20260325001",
  "bank_code": "MY_MBB",
  "account_number": "1234567890",
  "account_name": "Ahmad bin Ali",
  "method": "BANK"
}
```

> For e-wallet payouts (e.g. Touch 'n Go), use the wallet's registered number as `account_number` and the wallet's code (e.g. `MY_TNG`) as `bank_code` — `method` stays `BANK`.

## Response

```json
{
  "status": "success",
  "data": {
    "payment_id": "PAY_WD1A2B3C4D",
    "reference_id": "WD20260325001",
    "amount": 500.00,
    "currency": "MYR",
    "transaction_type": "WITHDRAWAL",
    "status": "PENDING",
    "gateway_reference": null,
    "created_at": "2026-03-25T10:30:00Z"
  }
}
```

### Response Fields

| Field               | Type   | Description                                                   |
| ------------------- | ------ | ------------------------------------------------------------- |
| `payment_id`        | string | Unique withdrawal identifier                                  |
| `reference_id`      | string | Your reference ID                                             |
| `amount`            | number | Confirmed withdrawal amount                                   |
| `currency`          | string | Currency code                                                 |
| `transaction_type`  | string | Always `"WITHDRAWAL"`                                         |
| `status`            | string | Initial status (`PENDING`)                                    |
| `gateway_reference` | string | Gateway reference (initially `null`, populated on processing) |
| `created_at`        | string | Creation timestamp (ISO 8601)                                 |

## Status Flow

```
PENDING → PROCESSING → SUCCESS
                     → FAILED
```

| Status       | Description                                       |
| ------------ | ------------------------------------------------- |
| `PENDING`    | Withdrawal request created, queued for processing |
| `PROCESSING` | Gateway is processing the withdrawal              |
| `SUCCESS`    | Funds transferred to beneficiary                  |
| `FAILED`     | Withdrawal was rejected or failed                 |

You will receive a [callback](/english/webhooks.md) notification when the withdrawal reaches a terminal status (`SUCCESS` or `FAILED`).

## Withdrawal Errors

| Error Code             | HTTP Status | Description                                                       |
| ---------------------- | ----------- | ----------------------------------------------------------------- |
| `VALIDATION_ERROR`     | 400         | One or more fields failed validation                              |
| `INVALID_AMOUNT`       | 400         | Amount outside allowed range                                      |
| `INVALID_BANK_CODE`    | 400         | Bank code not supported. See [Bank Codes](/english/bank-codes.md) |
| `DUPLICATE_REFERENCE`  | 409         | `reference_id` has already been used                              |
| `NO_GATEWAY_AVAILABLE` | 503         | No active withdrawal gateway                                      |
| `GATEWAY_ERROR`        | 502         | Upstream gateway returned an error                                |


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.jgopay.com/english/create-withdrawal.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
