Create a subscription
POSThttps://euwest.api.elasticpath.com/v2/subscriptions/subscriptions
Create a subscription
Request
Responses
- 201
- 400
- 500
Success. The subscription is created.
Bad request. The request failed validation.
Internal server error. There was a system failure in the platform.
Authorization: http
name: BearerTokentype: httpscheme: bearer
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://euwest.api.elasticpath.com/v2/subscriptions/subscriptions");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"external_ref\": \"abc123\",\n \"account_id\": \"11111111-2222-3333-4444-555555555555\",\n \"address_id\": \"11111111-2222-3333-4444-555555555555\",\n \"offering_external_ref\": \"abc123\",\n \"offering_id\": \"11111111-2222-3333-4444-555555555555\",\n \"plan_id\": \"11111111-2222-3333-4444-555555555555\",\n \"currency\": \"USD\",\n \"payment_authority\": {\n \"type\": \"elastic_path_payments_stripe\",\n \"customer_id\": \"cus_OPfKlxWV3hp9h6\",\n \"card_id\": \"card_8Diw3FQPhxK27WADPVMeXieP\"\n },\n \"manual_payments\": false,\n \"name\": \"Albert Einstein\",\n \"email\": \"albert@elasticpath.com\",\n \"pending\": false,\n \"first_invoice_paid\": false,\n \"started_at\": \"2017-01-10T11:41:19.244842Z\",\n \"offering\": {\n \"external_ref\": \"abc123\",\n \"name\": \"Magazine\",\n \"description\": \"A lovely magazine that is published every month.\"\n },\n \"products\": [\n {\n \"external_ref\": \"abc123\",\n \"name\": \"Magazine\",\n \"description\": \"A lovely magazine that is published every month.\",\n \"sku\": \"MAGAZINE1\",\n \"main_image\": \"https://magazine.com/cover.jpg\",\n \"price\": {\n \"USD\": {\n \"amount\": 100,\n \"includes_tax\": false\n },\n \"GBP\": {\n \"amount\": 90,\n \"includes_tax\": true\n }\n },\n \"price_units\": {\n \"unit\": \"day\",\n \"amount\": 7\n }\n }\n ],\n \"plans\": [\n {\n \"external_ref\": \"abc123\",\n \"name\": \"Monthly\",\n \"description\": \"A monthly subscription.\",\n \"billing_interval_type\": \"month\",\n \"billing_frequency\": 1,\n \"trial_period\": 7,\n \"plan_length\": 12,\n \"end_behavior\": \"close\",\n \"can_pause\": false,\n \"can_resume\": false,\n \"can_cancel\": false,\n \"base_price_percentage\": 90,\n \"fixed_price\": {\n \"USD\": {\n \"amount\": 100,\n \"includes_tax\": false\n },\n \"GBP\": {\n \"amount\": 90,\n \"includes_tax\": true\n }\n },\n \"meta\": {\n \"selected\": true\n }\n }\n ],\n \"selected_plan\": \"abc123\"\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear