Create subscription
POST {{base_url}}/v1/billing/subscriptions
Creates a subscription.
Request Body
{"plan_id"=>"{{billing_plan_id}}", "start_time"=>"{{tomorrow}}", "shipping_amount"=>{"currency_code"=>"USD", "value"=>"10.00"}, "subscriber"=>{"name"=>{"given_name"=>"FooBuyer", "surname"=>"Jones"}, "email_address"=>"foobuyer@example.com", "shipping_address"=>{"name"=>{"full_name"=>"John Doe"}, "address"=>{"address_line_1"=>"2211 N First Street", "address_line_2"=>"Building 17", "admin_area_2"=>"San Jose", "admin_area_1"=>"CA", "postal_code"=>"95131", "country_code"=>"US"}}}, "application_context"=>{"brand_name"=>"Example Inc", "locale"=>"en-US", "shipping_preference"=>"SET_PROVIDED_ADDRESS", "user_action"=>"SUBSCRIBE_NOW", "payment_method"=>{"payer_selected"=>"PAYPAL", "payee_preferred"=>"IMMEDIATE_PAYMENT_REQUIRED"}, "return_url"=>"https://example.com/return", "cancel_url"=>"https://example.com/cancel"}}
HEADERS
Key | Datatype | Required | Description |
---|---|---|---|
Content-Type | string | The Content-Type header field is used to specify the nature of the data in the body of an entity. PayPal REST APIs support application/json. | |
PayPal-Request-Id | string | The server stores keys for 72 hours. | |
PayPal-Client-Metadata-Id | string | Optional. Verifies that the payment originates from a valid, user-consented device and application. Reduces fraud and decreases declines. Transactions that do not include a client metadata ID are not eligible for PayPal Seller Protection. | |
PayPal-Partner-Attribution-Id | string | Optional. Identifies the caller as a PayPal partner. To receive revenue attribution, specify a unique build notation (BN) code. BN codes provide tracking on all transactions that originate or are associated with a particular partner. To find your BN code, see Code and Credential Reference. | |
PayPal-Auth-Assertion | string | An API client-provided JSON Web Token (JWT) assertion that identifies the merchant. To use this header, you must get consent to act on behalf of a merchant. | |
Prefer | string | The preferred server response upon successful completion of the request. Value is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code> and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource representation, including the current state of the resource.</li></ul> | |
Prefer | string | The preferred server response upon successful completion of the request. Value is:<ul><li><code>return=minimal</code>. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the <code>id</code>, <code>status</code> and HATEOAS links.</li><li><code>return=representation</code>. The server returns a complete resource representation, including the current state of the resource.</li></ul> |
RESPONSES
status: Created
{"status":"ACTIVE","status_update_time":"2022-02-08T22:35:04Z","id":"I-3AKFGBK4WBWN","plan_id":"P-7YC896222K2322022MIBO7QQ","start_time":"2022-02-08T22:35:04Z","quantity":"1","subscriber":{"payment_source":{"card":{"last_digits":"4242","brand":"VISA","expiry":"2024-02"}}},"create_time":"2022-02-08T22:35:04Z","plan_overridden":false,"links":[{"href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3AKFGBK4WBWN/cancel","rel":"cancel","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3AKFGBK4WBWN","rel":"edit","method":"PATCH"},{"href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3AKFGBK4WBWN","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3AKFGBK4WBWN/suspend","rel":"suspend","method":"POST"},{"href":"https://api.sandbox.paypal.com/v1/billing/subscriptions/I-3AKFGBK4WBWN/capture","rel":"capture","method":"POST"}]}