Skip to main content

Create a subscription

POST 

https://euwest.api.elasticpath.com/v2/subscriptions/subscriptions

Create a subscription

Request

Responses

Success. The subscription is created.

Authorization: http

name: BearerTokentype: httpscheme: bearer
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());
Request Collapse all
Base URL
https://euwest.api.elasticpath.com/v2
Auth
Parameters
— query
Body
{
  "data": {
    "external_ref": "abc123",
    "account_id": "11111111-2222-3333-4444-555555555555",
    "address_id": "11111111-2222-3333-4444-555555555555",
    "offering_external_ref": "abc123",
    "offering_id": "11111111-2222-3333-4444-555555555555",
    "plan_id": "11111111-2222-3333-4444-555555555555",
    "currency": "USD",
    "payment_authority": {
      "type": "elastic_path_payments_stripe",
      "customer_id": "cus_OPfKlxWV3hp9h6",
      "card_id": "card_8Diw3FQPhxK27WADPVMeXieP"
    },
    "manual_payments": false,
    "name": "Albert Einstein",
    "email": "albert@elasticpath.com",
    "pending": false,
    "first_invoice_paid": false,
    "started_at": "2017-01-10T11:41:19.244842Z",
    "offering": {
      "external_ref": "abc123",
      "name": "Magazine",
      "description": "A lovely magazine that is published every month."
    },
    "products": [
      {
        "external_ref": "abc123",
        "name": "Magazine",
        "description": "A lovely magazine that is published every month.",
        "sku": "MAGAZINE1",
        "main_image": "https://magazine.com/cover.jpg",
        "price": {
          "USD": {
            "amount": 100,
            "includes_tax": false
          },
          "GBP": {
            "amount": 90,
            "includes_tax": true
          }
        },
        "price_units": {
          "unit": "day",
          "amount": 7
        }
      }
    ],
    "plans": [
      {
        "external_ref": "abc123",
        "name": "Monthly",
        "description": "A monthly subscription.",
        "billing_interval_type": "month",
        "billing_frequency": 1,
        "trial_period": 7,
        "plan_length": 12,
        "end_behavior": "close",
        "can_pause": false,
        "can_resume": false,
        "can_cancel": false,
        "base_price_percentage": 90,
        "fixed_price": {
          "USD": {
            "amount": 100,
            "includes_tax": false
          },
          "GBP": {
            "amount": 90,
            "includes_tax": true
          }
        },
        "meta": {
          "selected": true
        }
      }
    ],
    "selected_plan": "abc123"
  }
}
ResponseClear

Click the Send API Request button above and see the response here!

We use cookies to enhance your experience. By continuing to visit this site you agree to our use of cookies.