# Create a subscription (Server2Server)

## Create a new subscription with credit card details

> This endpoint allows PCI merchants to create a new subscription with direct credit card details.

```json
{"openapi":"3.0.0","info":{"title":"Subscription API (PCI)","version":"3.0.0"},"servers":[{"url":"https://cc-api-stg.onekeypayments.com","description":"Staging Server (PCI)"}],"paths":{"/v3/subscriptions":{"post":{"summary":"Create a new subscription with credit card details","description":"This endpoint allows PCI merchants to create a new subscription with direct credit card details.","operationId":"createSubscriptionPCI","parameters":[{"name":"Content-Type","in":"header","description":"Media type of the body sent to the API.","required":true,"schema":{"type":"string","default":"application/json"}},{"name":"X-Date","in":"header","description":"ISO8601 Datetime with Timezone (yyyy-MM-dd'T'HH:mm:ssZ)","required":true,"schema":{"type":"string","format":"date-time"}},{"name":"X-Login","in":"header","description":"Merchant X-Login API Key.","required":true,"schema":{"type":"string"}},{"name":"Authorization","in":"header","description":"Authorization control hash.","required":true,"schema":{"type":"string"}},{"name":"X-Idempotency-Key","in":"header","description":"Unique idempotency key for ensuring that the same request is not processed more than once.","required":false,"schema":{"type":"string"}}],"requestBody":{"description":"Subscription details with credit card information","required":true,"content":{"application/json":{"schema":{"$ref":"#/components/schemas/SubscriptionRequestPCI"}}}},"responses":{"200":{"description":"Subscription created successfully","content":{"application/json":{"schema":{"type":"object","properties":{"subscription_id":{"type":"integer","description":"Unique identifier of the created subscription"}}}}}},"400":{"description":"Bad Request - Invalid input data","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"422":{"description":"Unprocessable Entity - Validation error","content":{"application/json":{"schema":{"$ref":"#/components/schemas/Error"}}}},"503":{"description":"Service Unavailable - Error creating subscription","content":{"application/json":{"schema":{"type":"object","properties":{"code":{"type":"integer"},"description":{"type":"string"}}}}}}},"tags":["Subscriptions"]}}},"components":{"schemas":{"SubscriptionRequestPCI":{"type":"object","required":["invoice_id","amount","currency","country","payer","subscription","credit_card"],"properties":{"invoice_id":{"type":"string","description":"Unique identifier for the invoice"},"amount":{"type":"number","format":"double","description":"Amount to be charged for the subscription"},"currency":{"type":"string","description":"Three-letter currency code (ISO 4217)"},"country":{"type":"string","description":"Two-letter country code (ISO 3166-1 alpha-2)"},"payer":{"$ref":"#/components/schemas/Payer"},"description":{"type":"string","description":"Description of the subscription"},"subscription":{"$ref":"#/components/schemas/SubscriptionDetails"},"credit_card":{"$ref":"#/components/schemas/CreditCard"},"client_ip":{"type":"string","description":"IP address of the client"},"back_url":{"type":"string","format":"uri","description":"URL to redirect after payment process"},"success_url":{"type":"string","format":"uri","description":"URL to redirect after successful payment"},"error_url":{"type":"string","format":"uri","description":"URL to redirect after failed payment"},"notification_url":{"type":"string","format":"uri","description":"URL to send payment status notifications"}}},"Payer":{"type":"object","required":["id","document","document_type","email","first_name","last_name"],"properties":{"id":{"type":"string","description":"Unique identifier for the payer"},"document":{"type":"string","description":"Payer's identification document number"},"document_type":{"type":"string","description":"Type of identification document"},"email":{"type":"string","format":"email","description":"Payer's email address"},"first_name":{"type":"string","description":"Payer's first name"},"last_name":{"type":"string","description":"Payer's last name"}}},"SubscriptionDetails":{"type":"object","required":["start_date","plan","plan_unit"],"properties":{"start_date":{"type":"string","format":"date","description":"Date when the subscription should start (YYYY-MM-DD)"},"plan":{"type":"string","description":"Frequency of the subscription (DAILY, WEEKLY, MONTHLY, ANNUALLY)","enum":["DAILY","WEEKLY","MONTHLY","ANNUALLY"]},"plan_unit":{"type":"integer","description":"Number of plan units (e.g., 1 for monthly, 3 for quarterly)"},"auto_renewal":{"type":"boolean","description":"Whether the subscription should automatically renew","default":false}}},"CreditCard":{"type":"object","required":["cvv","card_number","expiration_month","expiration_year","holder_name"],"properties":{"cvv":{"type":"string","description":"Card Verification Value"},"card_number":{"type":"string","description":"Credit card number"},"expiration_month":{"type":"string","description":"Expiration month (MM)"},"expiration_year":{"type":"string","description":"Expiration year (YY)"},"holder_name":{"type":"string","description":"Name of the card holder"}}},"Error":{"type":"object","properties":{"code":{"type":"integer","description":"Error code"},"description":{"type":"string","description":"Error description"},"type":{"type":"string","description":"Error type"}},"required":["code","description","type"]}}}}
```


---

# Agent Instructions: 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:

```
GET https://apidocs.onekeypayments.com/api-reference/deposits-api/manage-subscriptions/create-a-subscription-server2server.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
