GET /user/{userId}/subscriptions
Requires authentication with server or user access token.
List all the user's subscriptions within this client.
See also
Help us improve
Did you spot an error? Or maybe you just have a suggestion for how we can improve? Leave us a comment.
Request
GET /api/2/user/{userId}/subscriptions
userId | required path parameterThe user's |
---|
Example request
cURL
curl https://login.schibsted.com/api/2/user/42/subscriptions -G \
-d "oauth_token=[access token]"
Java
SpidOAuthToken token = spidClient.getUserToken(code);
String responseJSON = spidClient.
GET(token, "/user/42/subscriptions").
getResponseBody();
This example is an excerpt, see a full example
PHP
<?php
$client->auth();
echo var_dump($client->api("/user/42/subscriptions"));
This example is an excerpt, see a full example
Clojure
(ns example
(:require [spid-client-clojure.core :as spid]))
(let [client (spid/create-client "[client-id]" "[secret]")
token (spid/create-user-token client "[code]")]
(spid/GET client token "/user/42/subscriptions"))
Response
This endpoint supports the JSON and JSON-P response formats.
Success: 200 OK
Retrieves all subscriptions for user.
Returns a collection of Subscriptions, as an object withsubscriptionId
for property names, and Subscriptions for values.Subscription
subscriptionId ✓ | stringUnique ID of the subscription |
---|---|
originalSubscriptionId ✓ | stringUnique ID of the original subscription, if empty this is the first time user bought subscription for product |
clientId ✓ | stringYour client ID |
userId ✓ | stringUser id who bought the subscription |
productId ✓ | stringUnique product ID |
parentProductId | stringID of the parent product, if any |
identifierId ✓ | stringID of the payment identifier that will be used to renew the subscription |
paymentType ✓ | Payment type0 for SPiD Platform, 1 for Payment Platform |
orderId ✓ | stringID of the original order |
startDate ✓ | datetimeFrom when the subscription is/was active |
originalPurchaseDate ✓ | datetimeWhen the subscription was originally purchased |
expires ✓ | datetimeWhen the subscription expires |
autoRenew ✓ | string, "1" (true) or "0" (false)If |
renewPrice ✓ | priceThe price of renewal, in cents |
currency ✓ | stringThe renewal price currency |
renewPeriod ✓ | timestamp, in secondsRenewal period |
autoRenewLockPeriod ✓ | timestamp, in secondsLength of the initial period after activation during which it is not allowed to change the auto renew setting for the subscription. |
stopRenewalAfterLock ✓ | string, "1" (true) or "0" (false)When |
autoRenewDisabled ✓ | string, "1" (true) or "0" (false)When |
gracePeriod | timestamp, in secondsThe length of the period the subscription stays active after charging for a renewal fails. |
emailReceiptCount ✓ | integer (as string)The number of receipts sent via email to the user |
finalEndDate | datetimeIf provided, this date denotes the time when the subscription will no longer be available for sale. |
chargeRetryCount ✓ | integer (as string)The number of times the previous charge has been retried |
chargeLastRetry | datetimeTime of the last charge retry |
status ✓ | Subscription statusThe subscription's current status |
statusChangeCode | Subscription status change codeA description of the last change to the subscription's status |
statusChangeDate | datetimeThe date of the last change to the subscription's status |
updated ✓ | datetimeDate and time of last update to the subscription |
created ✓ | datetimeDate and time when the subscription was created |
product ✓ | ProductThe product this subscription belongs to |
The check mark ✓ indicates that the field always contains a valid non-empty value.
Subscription status
An enum, with the following possible values:
| Expired |
---|---|
| Inactive |
| Active |
Subscription status change code
An enum, with the following possible values:
| Subscription expired via multiple failed payment method charge attempts |
---|---|
| Subscription expired via API |
| Subscription expired passively (auto_renew is off) |
| Subscription expired by force |
| Subscription expired because it is no longer for sale |
| Subscription expired because it was renewed (i.e., a new subscription has been created) |
| Subscription expired because the user deleted their account |
| Subscription was paused |
| Expiry date was changed |
| Subscription expired because the user disabled auto renewal |
Failure cases
Some HTTP response codes are used for multiple error situations. There is no consistent way to tell these apart, but the error object will contain a textual explanation of the reason for the error. For explanation on OAuth related failures and errors see OAuth authentication failures.
- 401 Unauthorized You don't have administration rights for this client.
- 401 Unauthorized Your client doesn't have administration rights for this client.
- 403 Forbidden Client is not authorized to access this API endpoint. Contact SPiD to request access.
- 403 Forbidden Requesting IP is not whitelisted
- 403 Forbidden Access token rejected
- 404 Not Found Unknown client ID
- 404 Not Found Client ID mismatch. The client making the request is no the owner of this resource, and does not have administrative privileges for it.
- 420 Request Ratelimit exceeded
Sample response
JSON
{
"165937": {
"subscriptionId": "165937",
"clientId": "4e8463569caf7ca019000007",
"userId": "2200090",
"productId": "10012",
"parentProductId": "10010",
"identifierId": "0",
"orderId": "10722405",
"startDate": "2012-01-24 15:09:46",
"originalPurchaseDate": "2012-01-24 10:38:39",
"expires": "2012-04-23 11:39:22",
"autoRenew": "1",
"renewPrice": "2900",
"currency": "SEK",
"renewPeriod": "2592000",
"autoRenewLockPeriod": "0",
"autoRenewDisabled": "0",
"gracePeriod": "777600",
"emailReceiptCount": "0",
"finalEndDate": null,
"chargeRetryCount": "0",
"chargeLastRetry": null,
"status": "1",
"statusChangeCode": null,
"statusChangeDate": null,
"updated": "2012-01-27 18:35:30",
"created": "2012-01-24 15:09:46",
"product": {
"productId": "10012",
"parentProductId": "10010",
"clientId": "4e8463569caf7ca019000007",
"type": "2",
"code": "10012-PLUS1M",
"name": "Plus månadsprenumeration",
"description": "Plus 1 mån, därefter 29 kr/mån",
"url": null,
"price": "2900",
"vat": "2500",
"currency": "SEK",
"paymentOptions": "6",
"quantityLimit": null,
"quantityCount": "3",
"saleStart": "1970-01-01 00:00:00",
"saleStop": "2040-01-01 00:00:00",
"availableStart": null,
"availableStop": null,
"subscriptionPeriod": "2592000",
"subscriptionRenewPrice": "2900",
"subscriptionRenewPeriod": "2592000",
"subscriptionAutoRenew": "1",
"subscriptionAutoRenewLockPeriod": "0",
"subscriptionAutoRenewDisabled": "0",
"subscriptionGracePeriod": "777600",
"subscriptionEmailReceiptLimit": "0",
"subscriptionFinalEndDate": null,
"allowMultiSales": "1",
"status": "3",
"changedBy": null,
"changed": null,
"createdBy": "admin",
"created": "1970-01-01 00:00:00",
"purchaseUri": "https://spp.dev/auth/start?client_id=4e8463569caf7ca019000007&flow=payment&product_id=10012"
},
"statusMsg": "Active"
}
}
JSON-P
callback({
"165937": {
"subscriptionId": "165937",
"clientId": "4e8463569caf7ca019000007",
"userId": "2200090",
"productId": "10012",
"parentProductId": "10010",
"identifierId": "0",
"orderId": "10722405",
"startDate": "2012-01-24 15:09:46",
"originalPurchaseDate": "2012-01-24 10:38:39",
"expires": "2012-04-23 11:39:22",
"autoRenew": "1",
"renewPrice": "2900",
"currency": "SEK",
"renewPeriod": "2592000",
"autoRenewLockPeriod": "0",
"autoRenewDisabled": "0",
"gracePeriod": "777600",
"emailReceiptCount": "0",
"finalEndDate": null,
"chargeRetryCount": "0",
"chargeLastRetry": null,
"status": "1",
"statusChangeCode": null,
"statusChangeDate": null,
"updated": "2012-01-27 18:35:30",
"created": "2012-01-24 15:09:46",
"product": {
"productId": "10012",
"parentProductId": "10010",
"clientId": "4e8463569caf7ca019000007",
"type": "2",
"code": "10012-PLUS1M",
"name": "Plus månadsprenumeration",
"description": "Plus 1 mån, därefter 29 kr/mån",
"url": null,
"price": "2900",
"vat": "2500",
"currency": "SEK",
"paymentOptions": "6",
"quantityLimit": null,
"quantityCount": "3",
"saleStart": "1970-01-01 00:00:00",
"saleStop": "2040-01-01 00:00:00",
"availableStart": null,
"availableStop": null,
"subscriptionPeriod": "2592000",
"subscriptionRenewPrice": "2900",
"subscriptionRenewPeriod": "2592000",
"subscriptionAutoRenew": "1",
"subscriptionAutoRenewLockPeriod": "0",
"subscriptionAutoRenewDisabled": "0",
"subscriptionGracePeriod": "777600",
"subscriptionEmailReceiptLimit": "0",
"subscriptionFinalEndDate": null,
"allowMultiSales": "1",
"status": "3",
"changedBy": null,
"changed": null,
"createdBy": "admin",
"created": "1970-01-01 00:00:00",
"purchaseUri": "https://spp.dev/auth/start?client_id=4e8463569caf7ca019000007&flow=payment&product_id=10012"
},
"statusMsg": "Active"
}
});
Comments/feedback
Do you have questions, or just want to contribute some newly gained insight? Want to share an example? Please leave a comment. SPiD reads and responds to every question. Additionally, your experience can help others using SPiD, and it can help us continuously improve our documentation.