Skip to main content

Update a subscription

PUT 

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

Updates a subscription. For example, a subscriber can switch from one plan to another in a subscription.

Request

Path Parameters

    subscription_uuid UUIDrequired

    The unique identifier of the subscription.

Body

    data SubscriptionUpdaterequired
    idUUID (string)required

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    typeSubscriptionType (string)required

    Possible values: [subscription]

    Example: subscription
    attributes SubscriptionUpdateAttributesrequired
    plan_id
    Example: 00000000-0000-0000-0000-000000000001
    address_idUUIDnullable
    Example: 00000000-0000-0000-0000-000000000001
    payment_authority object
    type stringrequired

    Possible values: [elastic_path_payments_stripe, authorize_net]

    customer_idstring

    The unique identifier for a customer.

    Possible values: >= 3 characters and <= 1024 characters

    Example: cus_OPfKlxWV3hp9h6
    card_idstring

    The unique identifier of the card used to facilitate payment of the subscription. If a card payment fails, you can use the card_id and customer_id attributes to program your front-end implementation to allow your preferred payment service provider to update a subscription with new card details. See Card declines.

    Possible values: >= 3 characters and <= 1024 characters

    Example: card_8Diw3FQPhxK27WADPVMeXieP
    go_live_afterstringnullable

    The date and time a pending subscription goes live and becomes active. See Creating a pending subscription.

    Example: 2017-01-10T11:41:19.244842Z

Responses

Success. The subscription is updated.

Schema
    data Subscription
    idUUID (string)

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    typeSubscriptionType (string)required

    Possible values: [subscription]

    Example: subscription
    attributes SubscriptionAttributesrequired
    external_refExternalRef (string)

    A unique attribute that you could use to contain information from another company system, for example. The maximum length is 2048 characters.

    Possible values: <= 2048 characters

    Example: abc123
    account_idUUID (string)required

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    address_idUUID (string)

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    offering Offeringrequired
    idUUID (string)

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    typeSubscriptionOfferingType (string)required

    Possible values: [subscription_offering]

    Example: subscription_offering
    attributes OfferingResponseAttributes
    external_refExternalRef (string)

    A unique attribute that you could use to contain information from another company system, for example. The maximum length is 2048 characters.

    Possible values: <= 2048 characters

    Example: abc123
    namestringrequired

    The name of the offering.

    Possible values: >= 3 characters and <= 1024 characters

    Example: Magazine
    descriptionstring

    The offering description to display to customers.

    Possible values: <= 1024 characters

    Example: A lovely magazine that is published every month.
    updated_atstringrequired

    The date and time a resource was updated.

    Example: 2017-01-10T11:41:19.244842Z
    created_atstringrequired

    The date and time a resource was created.

    Example: 2017-01-10T11:41:19.244842Z
    relationships Relationships

    Relationships are established between different subscription entities. For example, a product and a plan are related to an offering, as both are attached to it.

    property name* Relationship
    anyOf
    meta OfferingMetarequired
    external_product_refsstring[]required
    ownerstringrequired

    The owner of a resource, either store or organization.

    Example: store
    timestamps Timestampsrequired
    updated_atstringrequired

    The date and time a resource was updated.

    Example: 2017-01-10T11:41:19.244842Z
    created_atstringrequired

    The date and time a resource was created.

    Example: 2017-01-10T11:41:19.244842Z
    plan_idUUID (string)required

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    currencyCurrencyIdentifier (string)required

    The three-letter ISO currency code in uppercase.

    Possible values: <= 1024 characters

    Example: USD
    payment_authority object
    type stringrequired

    Possible values: [elastic_path_payments_stripe, authorize_net]

    relationships Relationships

    Relationships are established between different subscription entities. For example, a product and a plan are related to an offering, as both are attached to it.

    property name* Relationship
    anyOf
    meta SubscriptionMetarequired
    ownerstringrequired

    The owner of a resource, either store or organization.

    Example: store
    timestamps SubscriptionTimestamps
    updated_atstringrequired

    The date and time a resource was updated.

    Example: 2017-01-10T11:41:19.244842Z
    created_atstringrequired

    The date and time a resource was created.

    Example: 2017-01-10T11:41:19.244842Z
    canceled_atstring

    The date and time a subscription was cancelled.

    Example: 2017-01-10T11:41:19.244842Z
    paused_atstring

    The date and time a subscription was paused.

    Example: 2017-01-10T11:41:19.244842Z
    resumed_atstring

    The date and time a subscription was resumed.

    Example: 2017-01-10T11:41:19.244842Z
    end_datestring

    The date and time a subscription will end.

    Example: 2017-01-10T11:41:19.244842Z
    go_live_afterstring

    The date and time a subscription will go live and become active.

    Example: 2017-01-10T11:41:19.244842Z
    go_livestring

    The date and time a subscription was released from the pending state and made active.

    Example: 2017-01-10T11:41:19.244842Z
    statusStatus (string)required

    The status of a subscription, either active or inactive.

    Possible values: [active, inactive]

    Example: active
    state SubscriptionState
    idUUID (string)

    The unique identifier.

    Example: 11111111-2222-3333-4444-555555555555
    typeSubscriptionStateType (string)required

    This represents the type of resource object being returned. Always subscription_state.

    Possible values: [subscription_state]

    Example: subscription_state
    attributes SubscriptionStateAttributesrequired
    actionSubscriptionStateAction (string)required

    The subscription lifecycle is the states that a subscription can go through when a customer subscribes to a service or a product.

    A subscription can have the following states; canceled, paused, or resumed.

    See Managing the subscription lifecycle.

    Possible values: [cancel, pause, resume, pending]

    Example: cancel
    meta StateMetarequired
    created_atstringrequired

    The date and time a resource was created.

    Example: 2017-01-10T11:41:19.244842Z
    manual_paymentsManualPayments (boolean)required

    When configured to true, no payment gateway is used and a pending payment is created. See External Payments.

    Default value: false
    Example: false
    first_invoice_prepaidbooleanrequired

    Indicates that the first billing period of this subscription was paid for outside of the subscriptions service.

    Example: false
    canceledbooleanrequired

    Whether a subscription is canceled or not.

    Example: true
    pausedbooleanrequired

    Whether a subscription is paused or not.

    Example: true
    closedbooleanrequired

    Whether a subscription is closed or not.

    Example: true
    suspendedbooleanrequired

    Whether a subscription is suspended or not.

    Example: false
    pendingbooleanrequired

    Whether a subscription is pending activation or not.

    Example: false
    invoice_afterstringrequired

    The time when the subscription becomes eligible for a new invoice. The next invoice will be generated at the next billing run after this point.

    Example: 2017-01-10T11:41:19.244842Z

Authorization: http

name: BearerTokentype: httpscheme: bearer
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Put, "https://euwest.api.elasticpath.com/v2/subscriptions/subscriptions/:subscription_uuid");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"id\": \"11111111-2222-3333-4444-555555555555\",\n \"type\": \"subscription\",\n \"attributes\": {\n \"plan_id\": \"00000000-0000-0000-0000-000000000001\",\n \"address_id\": \"00000000-0000-0000-0000-000000000001\",\n \"payment_authority\": {\n \"type\": \"elastic_path_payments_stripe\",\n \"customer_id\": \"cus_OPfKlxWV3hp9h6\",\n \"card_id\": \"card_8Diw3FQPhxK27WADPVMeXieP\"\n },\n \"go_live_after\": \"2017-01-10T11:41:19.244842Z\"\n }\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
— pathrequired
Body
{
  "data": {
    "id": "11111111-2222-3333-4444-555555555555",
    "type": "subscription",
    "attributes": {
      "plan_id": "00000000-0000-0000-0000-000000000001",
      "address_id": "00000000-0000-0000-0000-000000000001",
      "payment_authority": {
        "type": "elastic_path_payments_stripe",
        "customer_id": "cus_OPfKlxWV3hp9h6",
        "card_id": "card_8Diw3FQPhxK27WADPVMeXieP"
      },
      "go_live_after": "2017-01-10T11:41:19.244842Z"
    }
  }
}
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.