---
url: "https://docs.portone.cloud/docs/creating-an-on-demand-deduction"
title: "Creating an On-Demand Deduction"
---
This document provides a comprehensive guide to creating an **On-Demand Deduction** using the PortOne API. Merchants can perform deductions for subscriptions based on specific usage or amounts.
🦉
Subscription: Creating an OnDemand Deduction
Open Recipe
## **Steps to Create an On-Demand Deduction** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#steps-to-create-an-on-demand-deduction)
1. **Setup the PortOne Key, Secret, and JWT Token**: Ensure you have your `PortOne Key`, `Secret`, and `JWT Token` ready for authentication.
2. **Create Payload**: Prepare the JSON request body with all required parameters.
3. **Generate Signature Hash**: Generate the `signature_hash` as per the [On-Demand Deduction Signature Documentation](https://docs.portone.cloud/docs/ondemand-deduction).
4. **Call the API**: Use the endpoint to send the payload.
5. **Handle the Response**: Process the response to confirm the deduction's status.
* * *
## **API Endpoint** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#api-endpoint)
**POST** `https://api.portone.cloud/api/subscription/deduct`
* * *
## **Headers** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#headers)
##### `Content-Type` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#content-type)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan)
Set to `application/json`.
* * *
##### `X-Portone-Client-Key` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#x-portone-client-key)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-1)
The unique PortOne key for the merchant.
* * *
##### `Authorization` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#authorization)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-2)
JWT for authenticating API requests. Learn how to generate the token [here](https://docs.portone.cloud/docs/jwt-authentication).
* * *
## **Request Example** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#request-example)
### **On-Demand Deduction Request** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#on-demand-deduction-request)
#### Request Body: [Skip link to Request Body:](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#request-body)
JSON
```rdmd-code lang-json theme-light
{
"portone_key": "PORTONE_KEY",
"merchant_order_ref": "Merchant_1729672233763",
"subscription_order_ref": "2nsRMeHXpSUpe8DZzdyZkKCtI9D",
"description": "Product name for the customer's subscription purchase",
"source": "api",
"amount": 100,
"currency": "USD",
"environment": "sandbox"
}
```
## **Request Body Parameters** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#request-body-parameters)
##### `portone_key` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#portone_key)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-3)
The unique PortOne key for the merchant.
* * *
##### `signature_hash` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#signature_hash)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-4)
Signature hash generated as per [On-Demand Deduction Request Signature Documentation](https://docs.portone.cloud/docs/ondemand-deduction).
* * *
##### `merchant_order_ref` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#merchant_order_ref)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-5)
The unique merchant order reference generated by the merchant.
* * *
##### `subscription_order_ref` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#subscription_order_ref)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-6)
The unique subscription order reference of the subscription link.
* * *
##### `description` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#description)
###### _string_ [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string)
Product name for the customer's subscription purchase.
* * *
##### `source` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#source)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-7)
The source of creation: `default`, `api`, or `checkout`.
* * *
##### `amount` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#amount)
###### _double_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#double-%C2%B7-span-stylecolorredrequiredspan)
The amount of deduction (can be a floating-point number).
* * *
##### `currency` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#currency)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-8)
The currency of the subscription (e.g., `USD`).
* * *
##### `environment` [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#environment)
###### _string_ · required [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#string-%C2%B7-span-stylecolorredrequiredspan-9)
The environment of the transaction, either `sandbox` or `live`.
* * *
## **Response** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#response)
### **Success Response** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#success-response)
JSON
```rdmd-code lang-json theme-light
{
"is_success": true,
"merchant_order_ref": "Merchant_1729672233763",
"order_ref": "2nsRMeHXpSUpe8DZzdyZkKCtI9D",
"status_code": "200",
"status": "success"
}
```
### **Error Response** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#error-response)
JSON
```rdmd-code lang-json theme-light
{
"is_success": false,
"message": "The API request failed due to invalid parameters.",
"status_code": "400",
"status_reason": "Bad Request"
}
```
## **Best Practices** [Skip link to [object Object]](https://docs.portone.cloud/docs/creating-an-on-demand-deduction\#best-practices)
- **Environment Selection**: Use `sandbox` for testing and `live` for production.
- **Validation**: Validate all required fields before sending the request.
- **Monitoring**: Regularly monitor deduction statuses and logs.
* * *
This document serves as a comprehensive guide to creating **On-Demand Deductions** using the PortOne API.