Payment Services

GET /campaigns

Requires authentication with server access token.

List and search all campaigns.

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/campaigns

sort

optional

campaignId

optional

Find the campaign with this ID

title

optional

Find campaigns with title LIKE this

description

optional

Find campaigns with description LIKE this

status

optional

Filter results by this status

filters

optional
updated
Filter by recently updated items, order by last updated (should be used with since & until)
all
Include all items in the response, including deleted/blocked or otherwise excluded items
new
Return campaigns with status new
active
Filter by items with status active
unavailable
Return all items with status unavailable
deleted
Filter by items with a deleted status
products
Include campaign products in the response

The pagination parameters limit and offset are also supported.

Example request

cURL
Minimal example
curl https://login.schibsted.com/api/2/campaigns -G \
   -d "oauth_token=[access token]"
With all parameters
curl https://login.schibsted.com/api/2/campaigns -G \
   -d "oauth_token=[access token]" \
   -d "sort=userId" \
   -d "campaignId=23494" \
   -d "title=Freebies for all" \
   -d "description=Some information" \
   -d "status=0"
Java
Minimal example
SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    GET(token, "/campaigns").
    getResponseBody();
With all parameters
Map<String, String> params = new HashMap<>() {{
    put("sort", "userId");,
    put("campaignId", "23494");,
    put("title", "Freebies for all");,
    put("description", "Some information");,
    put("status", "0");
}};

SpidOAuthToken token = spidClient.getServerToken();
String responseJSON = spidClient.
    GET(token, "/campaigns", params).
    getResponseBody();

This example is an excerpt, see a full example

PHP
Minimal example
<?php
$client->auth();
echo var_dump($client->api("/campaigns"));
With all parameters
<?php
$params = array(
    "sort" => "userId",
    "campaignId" => "23494",
    "title" => "Freebies for all",
    "description" => "Some information",
    "status" => "0"
);

$client->auth();
echo var_dump($client->api("/campaigns", $params));

This example is an excerpt, see a full example

Clojure
Minimal example
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/GET client token "/campaigns"))
With all parameters
(ns example
  (:require [spid-client-clojure.core :as spid]))

(let [client (spid/create-client "[client-id]" "[secret]")
      token (spid/create-server-token client)]
  (spid/GET client token "/campaigns" {"sort" "userId"
                                       "campaignId" "23494"
                                       "title" "Freebies for all"
                                       "description" "Some information"
                                       "status" "0"}))

Response

This endpoint supports the JSON and JSON-P response formats.

Success: 200 OK

Returns a list of campaigns

Campaign

Campaigns are groups of products that may be given new prices when purchased through the campaign. For a campaign to be applied to a purchase, it’s campaignId needs to be part of the purchase URL. Campaigns may have limitations on their availability in time (start and stop dates), count (ie how many times it has been used), voucher (requires a valid voucher code to use) or address (the user must supply a physical address in order to use it).

Although campaigns are intended for temporary special offers, they may also be used as permanent way of getting lists of products. For this use case one has to be aware that the newPrice of campaign products does not update automatically if the product price is updated.

campaignId

integer (as string)

The campaign's unique ID. Needs to be part of any purchase URL that should have the campaign applied

clientId

string

ID of the client that owns this campaign

title

string

Campaign title

description

string

Additional campaign description

metaData

string

Not used by SPiD, for client-specific meta-data

startDate

datetime

When the campaign starts/becomes active

stopDate

datetime

When the campaign stops/ceases to be active

additionalReceiptInfo

string

Additional text to include in purchase receipts for this campaign

requireAddress

string, "1" (true) or "0" (false)

If "1", access to the campaign requires users to have a delivery address on their SPiD profile

requireVoucher

string, "1" (true) or "0" (false)

If "1", access to the campaign requires an available voucher code that belongs to a voucher group connected to this campaign

status

Campaign status

limit

integer (as string)

Maximum number of purchases allowed for this campaign

count

integer (as string)

The number of purchases made on this campaign so far

updated

datetime

When the campaign was last updated

created

datetime

When the campaign was created

products

list of Campaign products

The campaign's products

The check mark indicates that the field always contains a valid non-empty value.

Campaign status

An enum, with the following possible values:

"0"

New

"1"

Active

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.
  • 404 Not Found No campaign matched search criteria
  • 420 Request Ratelimit exceeded

Sample response

JSON
[
  {
    "status": "1",
    "clientId": "[Your client ID]",
    "additionalReceiptInfo": null,
    "requireVoucher": "0",
    "count": "0",
    "startDate": null,
    "title": "My Campaign",
    "created": "2014-04-23 14:28:30",
    "updated": "2014-04-23 14:28:30",
    "limit": null,
    "stopDate": null,
    "campaignId": "10044",
    "requireAddress": "0",
    "metaData": null,
    "description": null
  }
]
JSON-P
callback([
  {
    "status": "1",
    "clientId": "[Your client ID]",
    "additionalReceiptInfo": null,
    "requireVoucher": "0",
    "count": "0",
    "startDate": null,
    "title": "My Campaign",
    "created": "2014-04-23 14:28:30",
    "updated": "2014-04-23 14:28:30",
    "limit": null,
    "stopDate": null,
    "campaignId": "10044",
    "requireAddress": "0",
    "metaData": null,
    "description": null
  }
]);

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.