Subscriptions API

Overview

Methods for managing subscriptions. See the product guide and the glossary.

Endpoint path: https://api.xsolla.com.

UI

Opening UI

Use the following link to open the UI in a new window: https://secure.xsolla.com/paystation2/?access_token=ACCESS_TOKEN, where ACCESS_TOKEN is the token received via API.

Use the following URL for testing purposes: https://sandbox-secure.xsolla.com/paystation2/?access_token=ACCESS_TOKEN.

Notice: Parameter access_token contains private user data. Please make sure that you use server-to-server communication when getting this parameter.

Test Cards List

In the Sandbox you can use these cards to simulate successful payments:

Card3-D Secure
Card number: 4111111111111111
Exp. date: 12/40
CVV2: 123
Card type: VISA
No
Card number: 5555555555554444
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
No
Card number: 4000000000000010
Exp. date: 12/40
CVV2: 123
Card type: VISA
Yes
Card number: 5200000000000114
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
Yes
Card number: 6759649826438453
Exp. date: 12/40
CVV2: 321
Card type: Maestro
Yes

In addition, you can use the following data to simulate declined transactions:

Card3-D SecureDescription
Card number: 4000000000000002
Exp. date: 12/40
CVV2: 123
Card type: VISA
NoInsufficient funds
Card number: 5200000000000007
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
NoInsufficient funds
Card number: 4000000000000036
Exp. date: 12/40
CVV2: 123
Card type: VISA
YesDeclined
Card number: 5200000000000031
Exp. date: 11/40
CVV2: 321
Card type: MasterCard
YesDeclined

Errors List

CodeDescription
0004-0001Token expired or incorrect.
0004-0008Wrong URL (trying to access sandbox mode at secure.xsolla.com or live mode at sandbox-secure.xsolla.com).
0002-0004Agreement not signed.
0004-0010Tokenless integration prohibited.
0010-0001Package not found.
0010-0003Package has no DRM configured.
1000-0003No modules turned on for the project.

Subscriptions Management

Methods for managing subscriptions. See the product guide and the glossary.

Create Plan

Creates a subscription plan.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans

ParameterTypeDescription
project_id
integerProject ID.
external_id
stringPlan external ID (32 characters). Optional.
name
array of stringsPlan name. Value consists of pairs "localization":"plan name".
description
array of stringsPlan description. Value consists of pairs "localization":"plan description". Optional.
group_id
stringGroup ID the plans are linked to.
charge
objectBilling details (object).
charge.period
objectBilling period (object).
charge.period.value
integerNumber of time units.
charge.period.type
stringTime unit: day/month.
charge.amount
floatBilling amount.
charge.currency
stringCurrency of the purchase. Three-letter currency code per ISO 4217.
expiration
objectSubscription expiration details (object).
expiration.value
integerValidity time.
expiration.type
stringTime unit: day/month.
trial
objectTrial period details (object). Optional.
trial.value
integerTrial period.
trial.type
stringTime unit: day.
grace_period
objectGrace period details. Optional.
grace_period.value
integerGrace period.
grace_period.type
stringTime unit: day.
tags
arrayPlan tags. Optional.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "charge": {
    "amount": "10",
    "currency": "USD",
    "period": {
      "type": "month",
      "value": "1"
    }
  },
  "description": {
    "en": "2x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": null
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": "2"
  },
  "name": {
    "en": "Experience boost"
  },
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "trial": {
    "type": "day",
    "value": "7"
  }
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"charge":{"amount":"10","currency":"USD","period":{"value":"1","type":"month"}},"name":{"en":"Experience boost"},"description":{"en":"2x more experience!"},"trial":{"value":"7","type":"day"},"grace_period":{"value":"2","type":"day"},"external_id":"exp","expiration":{"value":null,"type":"day"},"status":{"value":"active","counters":{"active":0,"canceled":0,"frozen":0,"non_renewing":0}}}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"charge":{"amount":"10","currency":"USD","period":{"value":"1","type":"month"}},"name":{"en":"Experience boost"},"description":{"en":"2x more experience!"},"trial":{"value":"7","type":"day"},"grace_period":{"value":"2","type":"day"},"external_id":"exp","expiration":{"value":null,"type":"day"},"status":{"value":"active","counters":{"active":0,"canceled":0,"frozen":0,"non_renewing":0}}}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"charge\":{\"amount\":\"10\",\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"2x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"charge\":{\"amount\":\"10\",\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"2x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}}}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/projects/{project_id}/subscriptions/plans", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"charge\":{\"amount\":\"10\",\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"2x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}}}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"charge\":{\"amount\":\"10\",\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"2x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}}}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "charge": {
    "amount": "10",
    "currency": "USD",
    "period": {
      "value": "1",
      "type": "month"
    }
  },
  "name": {
    "en": "Experience boost"
  },
  "description": {
    "en": "2x more experience!"
  },
  "trial": {
    "value": "7",
    "type": "day"
  },
  "grace_period": {
    "value": "2",
    "type": "day"
  },
  "external_id": "exp",
  "expiration": {
    "value": null,
    "type": "day"
  },
  "status": {
    "value": "active",
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    }
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}
{
  "external_id": "exp",
  "plan_id": 241082
}

Update Plan Parameters

Updates subscription plan parameters.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

ParameterTypeDescription
project_id
integerProject ID.
plan_id
integerPlan ID.
external_id
stringPlan external ID (32 characters). Optional.
name
array of stringsPlan name. Value consists of pairs "localization":"plan name".
description
array of stringsPlan description. Value consists of pairs "localization":"plan description". Optional.
group_id
stringGroup ID the plans are linked to.
charge
objectBilling details (object).
charge.period
objectBilling period (object).
charge.period.value
integerNumber of time units.
charge.period.type
stringTime unit: day/month.
charge.amount
floatBilling amount.
charge.currency
stringCurrency of the purchase. Three-letter currency code per ISO 4217.
expiration
objectSubscription expiration details (object).
expiration.value
integerValidity time.
expiration.type
stringTime unit: day/month.
trial
objectTrial period details (object). Optional.
trial.value
integerTrial period.
trial.type
stringTime unit: day.
grace_period
objectGrace period details. Optional.
grace_period.value
integerGrace period.
grace_period.type
stringTime unit: day.
tags
arrayPlan tags. Optional.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • java
  • js
  • python
  • ruby
Request
PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": "1"
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": null
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": "2"
  },
  "name": {
    "en": "Experience boost"
  },
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": null,
  "trial": {
    "type": "day",
    "value": "7"
  }
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id} \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"charge":{"amount":20,"currency":"USD","period":{"value":"1","type":"month"}},"name":{"en":"Experience boost"},"description":{"en":"3x more experience!"},"trial":{"value":"7","type":"day"},"grace_period":{"value":"2","type":"day"},"external_id":"exp","expiration":{"value":null,"type":"day"},"status":{"value":"active","counters":{"active":0,"canceled":0,"frozen":0,"non_renewing":0}},"tags":null}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"charge":{"amount":20,"currency":"USD","period":{"value":"1","type":"month"}},"name":{"en":"Experience boost"},"description":{"en":"3x more experience!"},"trial":{"value":"7","type":"day"},"grace_period":{"value":"2","type":"day"},"external_id":"exp","expiration":{"value":null,"type":"day"},"status":{"value":"active","counters":{"active":0,"canceled":0,"frozen":0,"non_renewing":0}},"tags":null}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"charge\":{\"amount\":20,\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"3x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}},\"tags\":null}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"charge\":{\"amount\":20,\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"3x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}},\"tags\":null}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "value": "1",
      "type": "month"
    }
  },
  "name": {
    "en": "Experience boost"
  },
  "description": {
    "en": "3x more experience!"
  },
  "trial": {
    "value": "7",
    "type": "day"
  },
  "grace_period": {
    "value": "2",
    "type": "day"
  },
  "external_id": "exp",
  "expiration": {
    "value": null,
    "type": "day"
  },
  "status": {
    "value": "active",
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    }
  },
  "tags": null
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"charge\":{\"amount\":20,\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"3x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}},\"tags\":null}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"charge\":{\"amount\":20,\"currency\":\"USD\",\"period\":{\"value\":\"1\",\"type\":\"month\"}},\"name\":{\"en\":\"Experience boost\"},\"description\":{\"en\":\"3x more experience!\"},\"trial\":{\"value\":\"7\",\"type\":\"day\"},\"grace_period\":{\"value\":\"2\",\"type\":\"day\"},\"external_id\":\"exp\",\"expiration\":{\"value\":null,\"type\":\"day\"},\"status\":{\"value\":\"active\",\"counters\":{\"active\":0,\"canceled\":0,\"frozen\":0,\"non_renewing\":0}},\"tags\":null}"

response = http.request(request)
puts response.read_body
Response
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}
{
  "charge": {
    "amount": 20,
    "currency": "USD",
    "period": {
      "type": "month",
      "value": 1
    }
  },
  "description": {
    "en": "3x more experience!"
  },
  "expiration": {
    "type": "day",
    "value": 0
  },
  "external_id": "exp",
  "grace_period": {
    "type": "day",
    "value": 2
  },
  "group_id": null,
  "id": 241082,
  "localized_name": "Experience boost",
  "name": {
    "en": "Experience boost"
  },
  "project_id": 40797,
  "status": {
    "counters": {
      "active": 0,
      "canceled": 0,
      "frozen": 0,
      "non_renewing": 0
    },
    "value": "active"
  },
  "tags": [],
  "trial": {
    "type": "day",
    "value": 7
  },
  "type": "all"
}

Enable Plan

Enables a subscription plan.

HTTP REQUEST

PATCH https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

ParameterTypeDescription
project_id
integerProject ID.
plan_id
integerPlan ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PATCH https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "status": {
    "value": "active"
  }
}
curl --request PATCH \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id} \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"status":{"value":"active"}}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"status":{"value":"active"}}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}');
$request->setRequestMethod('PATCH');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
var request = new RestRequest(Method.PATCH);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"status\":{\"value\":\"active\"}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"status\":{\"value\":\"active\"}}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PATCH", "/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Patch.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"status\":{\"value\":\"active\"}}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"status\":{\"value\":\"active\"}}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")
  .patch(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "status": {
    "value": "active"
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PATCH", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Disable Plan

Disables a subscription plan.

HTTP REQUEST

DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

ParameterTypeDescription
project_id
integerProject ID.
plan_id
integerPlan ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request DELETE \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id} \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}');
$request->setRequestMethod('DELETE');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
var request = new RestRequest(Method.DELETE);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("DELETE", "/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}")
  .delete(null)
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Delete Plan

Deletes a subscription plan.

HTTP REQUEST

DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete

ParameterTypeDescription
project_id
integerProject ID.
plan_id
integerPlan ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request DELETE \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete');
$request->setRequestMethod('DELETE');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete");
var request = new RestRequest(Method.DELETE);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("DELETE", "/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete")
  .delete(null)
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans/{plan_id}/delete");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Plans

Lists all subscription plans.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans

ParameterTypeDescription
project_id
integerProject ID.
external_id
stringPlan external ID (32 characters).
limit
integerLimit for the number of elements on the page.
offset
integerNumber of the element from which the list is generated (the count starts from 0).
group_id
stringGroup ID the plans are linked to.
product_id
integerProduct ID the plans are linked to.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url 'https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10' \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
  'limit' => '10'
)));

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/plans?limit=10");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]
[
  {
    "charge": {
      "amount": 19.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "10x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "3b355320",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241037,
    "localized_name": "Platinum VIP",
    "name": {
      "en": "Platinum VIP",
      "fr": "Le VIP-statut platinum"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  {
    "charge": {
      "amount": 9.99,
      "currency": "USD",
      "period": {
        "type": "month",
        "value": 1
      }
    },
    "description": {
      "en": "3x more experience!"
    },
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "0fe1b6fc",
    "grace_period": {
      "type": "day",
      "value": 0
    },
    "group_id": null,
    "id": 241038,
    "localized_name": "Gold Status",
    "name": {
      "en": "Gold Status",
      "fr": "Le statut d’or"
    },
    "project_id": 40797,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  }
]

Create Product

Creates a subscription-based product.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products

ParameterTypeDescription
project_id
integerProject ID.
name
stringProduct name.
group_id
stringGroup ID the plans are linked to.
description
stringLocalized item descriptions (array).
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "description": [],
  "group_id": "charge",
  "name": "Channel2"
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"description":[],"group_id":"charge","name":"Channel2"}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"description":[],"group_id":"charge","name":"Channel2"}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"description\":[],\"group_id\":\"charge\",\"name\":\"Channel2\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"description\":[],\"group_id\":\"charge\",\"name\":\"Channel2\"}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/projects/{project_id}/subscriptions/products", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"description\":[],\"group_id\":\"charge\",\"name\":\"Channel2\"}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"description\":[],\"group_id\":\"charge\",\"name\":\"Channel2\"}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "description": [],
  "group_id": "charge",
  "name": "Channel2"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}
{
  "product_id": 171603
}

Update Product

Updates a subscription-based product.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}

ParameterTypeDescription
project_id
integerProject ID.
product_id
integerProduct ID the plans are linked to.
name
stringProduct name.
group_id
stringGroup ID the plans are linked to.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "description": [],
  "group_id": "charge1323",
  "name": "Channel2123"
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/ \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"description":[],"group_id":"charge1323","name":"Channel2123"}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"description":[],"group_id":"charge1323","name":"Channel2123"}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"description\":[],\"group_id\":\"charge1323\",\"name\":\"Channel2123\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"description\":[],\"group_id\":\"charge1323\",\"name\":\"Channel2123\"}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"description\":[],\"group_id\":\"charge1323\",\"name\":\"Channel2123\"}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"description\":[],\"group_id\":\"charge1323\",\"name\":\"Channel2123\"}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "description": [],
  "group_id": "charge1323",
  "name": "Channel2123"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}/");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}
{
  "description": [],
  "group_id": "charge13",
  "id": 1713603,
  "name": "Channel23"
}

Delete Product

Deletes a subscription-based product.

HTTP REQUEST

DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}

ParameterTypeDescription
project_id
integerProject ID.
product_id
integerProduct ID the plans are linked to.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
DELETE https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request DELETE \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id} \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}');
$request->setRequestMethod('DELETE');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}");
var request = new RestRequest(Method.DELETE);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("DELETE", "/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}")
  .delete(null)
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products/{product_id}");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Products

Lists all subscription-based products.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products

ParameterTypeDescription
project_id
integerProject ID.
group_id
stringGroup ID the plans are linked to.
product_id
integerProduct ID the plans are linked to.
limit
integerLimit for the number of elements on the page.
offset
integerNumber of the element from which the list is generated (the count starts from 0).
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/products", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/products");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]
[
  {
    "description": [],
    "group_id": "charge",
    "id": 714,
    "name": "Channel"
  },
  {
    "description": [],
    "group_id": "notify",
    "id": 715,
    "name": "notify"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 716,
    "name": "charge2"
  },
  {
    "description": [],
    "group_id": "charge",
    "id": 486,
    "name": "Channel2"
  }
]

Get Subscription

Gets a specific subscription details by ID.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}

ParameterTypeDescription
project_id
integerProject ID. Required.
subscription_id
integerSubscription ID. Required.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id} \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/{subscription_id}");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}

]
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}
{
  "charge_amount": 0.03,
  "comment": "The subscription was not extended in due time\r",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": "2019-02-06T12:43:04+0300",
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 249579,
  "plan": {
    "external_id": "lowcost",
    "id": 601
  },
  "product": null,
  "status": "canceled",
  "user": {
    "id": "user1",
    "name": "John Smith"
  }
}

Update Subscription

Updates a subscription by either changing its status ('active', 'canceled', or 'non_renewing') or postponing the next billing date.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}

ParameterTypeDescription
project_id
integerProject ID.
subscription_id
integerSubscription ID.
user_id
stringUser ID.
status
stringStatus: active/canceled/non_renewing.
cancel_subscription_payment
booleanSetting to true will refund the last payment made for this subscription. Only works together with setting the status to canceled.
timeshift
objectBilling postponement.
timeshift.type
stringBilling time unit, can be ‘day’ or ‘month’.
timeshift.value
stringNumber of time units to postpone the billing by. The value depends on the timeshift.type parameter and can be:
  • from 1 to 366, if timeshift.type is ‘day’
  • from 1 to 12, if timeshift.type is ‘month’
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "comment": "Canceled by the user with the latest payment refund",
  "status": "active"
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id} \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"comment":"Canceled by the user with the latest payment refund","status":"active"}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"comment":"Canceled by the user with the latest payment refund","status":"active"}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"comment\":\"Canceled by the user with the latest payment refund\",\"status\":\"active\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"comment\":\"Canceled by the user with the latest payment refund\",\"status\":\"active\"}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"comment\":\"Canceled by the user with the latest payment refund\",\"status\":\"active\"}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"comment\":\"Canceled by the user with the latest payment refund\",\"status\":\"active\"}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "comment": "Canceled by the user with the latest payment refund",
  "status": "active"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/{subscription_id}");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}
{
  "charge_amount": 0.03,
  "comment": "Canceled by the user with the latest payment refund",
  "currency": "USD",
  "date_create": "2018-09-21T16:54:59+0300",
  "date_end": null,
  "date_last_charge": "2018-09-21T16:55:05+0300",
  "date_next_charge": "2018-09-21T16:55:05+0300",
  "id": 24953579,
  "plan": {
    "charge": {
      "amount": 0.03,
      "currency": "USD",
      "period": {
        "type": "day",
        "value": 1
      }
    },
    "description": null,
    "expiration": {
      "type": "day",
      "value": 0
    },
    "external_id": "lowcost",
    "grace_period": {
      "type": "day",
      "value": 2
    },
    "group_id": "newPlans",
    "id": 66001,
    "localized_name": null,
    "name": null,
    "project_id": 18404,
    "status": {
      "counters": {
        "active": 0,
        "canceled": 0,
        "frozen": 0,
        "non_renewing": 0
      },
      "value": "active"
    },
    "tags": null,
    "trial": {
      "type": "day",
      "value": 0
    },
    "type": "all"
  },
  "product": null,
  "status": "active",
  "user": {
    "id": "jb1",
    "name": "J.Black"
  }
}

Get Subscriptions

Lists all recurrent subscriptions.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions

ParameterTypeDescription
merchant_id
integerMerchant ID. Required.
project_id
array of integersIDs for projects.
user_id
stringUser ID (v1).
plan_id
array of integersIDs for subscription plans.
product_id
array of integersIDs for subscription-based product.
group_id
array of stringsIDs for subscription groups.
status
array of integersStatus of Subscriptions.
datetime_from
datetimeSample date. Use this to find subscriptions created later than the request.
datetime_to
datetimeSample date. Use this to find subscriptions created earlier than the request.
limit
integerLimit for the number of elements on the page.
offset
integerNumber of the element from which the list is generated (the count starts from 0).
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/subscriptions", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/subscriptions");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]
[
  {
    "id": 45,
    "cost": 0.03,
    "dateCreate": "2013-09-05T15:27:47+0400",
    "dateEnd": "2014-02-06T11:32:48+0400",
    "dateLastCharge": null,
    "dateNextCharge": null,
    "email": "test@test.com",
    "currency": "USD",
    "user": "User1",
    "status": 2,
    "chargeAmount": "0.0300",
    "planId": 12345,
    "projectId": 12345,
    "productId": null,
    "productName": null,
    "name": {
      "en": "Example"
    }
  }
]

Get Payments

Lists all subscription payments.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments

ParameterTypeDescription
project_id
integerProject ID.
user_id
stringUser ID.
status
stringStatus: processing/canceled/done.
limit
integerLimit for the number of elements on the page.
offset
integerNumber of the element from which the list is generated (the count starts from 0).
datetime_from
datetimePeriod start.
datetime_to
datetimePeriod end.
subscription_id
integerSubscription ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url 'https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100' \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
  'limit' => '100'
)));

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?limit=100");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 67683,
    "id_payment": 203960,
    "status": "fail",
    "subscription": {
      "charge_amount": 1,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 3646,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nJ79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 12345,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "10",
        "name": "user2"
      }
    }
  },
  {
    "date_payment": "2015-09-21T17:06:47+0300",
    "id": 1531,
    "id_payment": 168866,
    "status": "done",
    "subscription": {
      "charge_amount": 1,
      "comment": "  \r\n",
      "currency": "RUB",
      "date_create": "2015-09-21T17:06:47+0300",
      "date_end": null,
      "date_last_charge": "2015-09-21T18:10:09+0300",
      "date_next_charge": "2015-09-22T18:10:09+0300",
      "id": 1204846,
      "plan": {
        "charge": {
          "amount": 1,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8nX9",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 240,
        "localized_name": null,
        "name": null,
        "project_id": 70,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": null,
      "status": "new",
      "user": {
        "id": "12",
        "name": "user1"
      }
    }
  }
]

Get User Payments

Lists all payments made by a specific user.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/users/{user_id}/subscriptions/payments

ParameterTypeDescription
project_id
integerProject ID.
user_id
stringUser ID.
status
stringStatus: processing/canceled/done.
limit
integerLimit for the number of elements on the page.
offset
integerNumber of the element from which the list is generated (the count starts from 0).
datetime_from
datetimePeriod start.
datetime_to
datetimePeriod end.
subscription_id
integerSubscription ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15:34:17&datetime_to=2017-04-05T15:34:17&limit=100&user_id=12

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url 'https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100' \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments');
$request->setRequestMethod('GET');
$request->setQuery(new http\QueryString(array(
  'datetime_from' => '2013-04-05T15:34:17',
  'datetime_to' => '2017-04-05T15:34:17',
  'user_id' => '12',
  'limit' => '100'
)));

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/payments?datetime_from=2013-04-05T15%3A34%3A17&datetime_to=2017-04-05T15%3A34%3A17&user_id=12&limit=100");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]
[
  {
    "date_payment": "2016-04-05T10:01:01+0300",
    "id": 6746083,
    "id_payment": 202789960,
    "status": "fail",
    "subscription": {
      "charge_amount": 100,
      "comment": null,
      "currency": "RUB",
      "date_create": "2015-05-28T14:33:54+0300",
      "date_end": "2016-04-05T10:01:07+0300",
      "date_last_charge": "2015-06-03T16:07:29+0300",
      "date_next_charge": "2015-06-04T00:00:00+0300",
      "id": 36946,
      "plan": {
        "charge": {
          "amount": 100,
          "currency": "RUB",
          "period": {
            "type": "day",
            "value": 1
          }
        },
        "description": null,
        "expiration": {
          "type": "day",
          "value": 0
        },
        "external_id": "E8n34J79",
        "grace_period": {
          "type": "day",
          "value": 0
        },
        "group_id": "charge",
        "id": 24,
        "localized_name": null,
        "name": null,
        "project_id": 1234,
        "status": {
          "counters": {
            "active": 0,
            "canceled": 0,
            "frozen": 0,
            "non_renewing": 0
          },
          "value": "deleted"
        },
        "tags": null,
        "trial": {
          "type": "day",
          "value": 0
        },
        "type": "charge"
      },
      "product": {
        "description": null,
        "group_id": "charge",
        "id": 1,
        "name": "charge"
      },
      "status": "freeze",
      "user": {
        "id": "12",
        "name": "John"
      }
    }
  }
]

Get Currencies

Lists all supported subscription currencies.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies

ParameterTypeDescription
project_id
integerProject ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/subscriptions/currencies", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/subscriptions/currencies");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]
[
  "AED",
  "ALL",
  "AMD",
  "ARS",
  "AUD",
  "AZN",
  "BAM",
  "BBD",
  "BGN",
  "BHD",
  "BND",
  "BRL",
  "BYN",
  "BZD",
  "CAD",
  "CHF",
  "CLP",
  "CNY",
  "COP",
  "CRC",
  "CZK",
  "DKK",
  "DZD",
  "EGP",
  "EUR",
  "GBP",
  "GEL",
  "GHS",
  "GIP",
  "GTQ",
  "HKD",
  "HRK",
  "HUF",
  "IDR",
  "ILS",
  "INR",
  "IQD",
  "IRR",
  "ISK",
  "JMD",
  "JOD",
  "JPY",
  "KES",
  "KGS",
  "KRW",
  "KWD",
  "KZT",
  "LAK",
  "LBP",
  "LKR",
  "MAD",
  "MDL",
  "MKD",
  "MMK",
  "MNT",
  "MUR",
  "MXN",
  "MYR",
  "NGN",
  "NIO",
  "NOK",
  "NPR",
  "NZD",
  "OMR",
  "PAB",
  "PEN",
  "PHP",
  "PKR",
  "PLN",
  "PYG",
  "QAR",
  "RON",
  "RSD",
  "RUB",
  "SAR",
  "SEK",
  "SGD",
  "SVC",
  "THB",
  "TND",
  "TRY",
  "TWD",
  "UAH",
  "USD",
  "UYU",
  "UZS",
  "VEF",
  "VND",
  "XOF",
  "YER",
  "ZAR"
]

Coupons

Get Coupon

Get coupon details by its code.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/details 

ParameterTypeDescription
project_id
integerProject ID.
code
stringCoupon code.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/details  

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{coupon_id}/details");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "12345",
  "coupon_code": "1234",
  "coupon_id": 89613970,
  "expiration_date": "2019-02-02 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": ,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}

Redeem Coupon

Redeem a coupon by its code.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem

ParameterTypeDescription
project_id
integerProject ID.
code
stringCoupon code.
user_id
stringUser ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "user_id": 1234
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"user_id":1234}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"user_id":1234}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"user_id\":1234}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"user_id\":1234}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/projects/{project_id}/coupons/{code}/redeem", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"user_id\":1234}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"user_id\":1234}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "user_id": 1234
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/projects/{project_id}/coupons/{code}/redeem");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}
{
  "campaign_code": "new_campaign",
  "coupon_code": "ddgf5bn4",
  "coupon_id": 89613996,
  "expiration_date": "2019-12-31 00:00:00",
  "is_active": 1,
  "project_id": 12345,
  "redeems_count_for_user": 10,
  "redeems_count_remain": 20,
  "subscription_coupon": null,
  "virtual_currency_amount": 100,
  "virtual_items": []
}

Create Campaign

Create a new coupon campaign.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions

ParameterTypeDescription
merchant_id
integerMerchant ID. Required.
campaign_code
stringCampaign name. Required.
project_id
integerProject ID. Required.
campaign_names
objectObject containing localized campaign names. Required.
expiration_date
datetimeCampaign expiration date in the YYYY-MM-DD’T’HH:MM:SS format per ISO 8601.
virtual_currency_amount
floatVirtual currency amount in a reward.
virtual_items
arrayArray of virtual items parameters in a reward.
virtual_items.sku
stringVirtual item SKU. Required if the virtual_items array is passed.
virtual_items.quantity
integerVirtual items quantity. Required if the virtual_items array is passed.
subscription_coupon
objectObject containing subscription parameters in a reward.
subscription_coupon.plan_id
integerSubscription plan ID. Required if the subscription_coupon object is passed.
subscription_coupon.product_id
integerSubscription product ID. Required if the subscription_coupon object is passed.
trial_period
integerTrial period duration in days. Required if the subscription_coupon object is passed.
redeems_count
integerMaximum number of coupon redeems. If ‘null’ is passed, the redeems number is unlimited.
redeems_count_for_user
integerMaximum number of coupon redeems per user. If ‘null’ is passed, the redeems number is unlimited.
campaign_redeems_count_for_user
integerMaximum number of coupon redeems per user within a campaign. If ‘null’ is passed, the redeems number is unlimited.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "campaign_code": "sample_campaign",
  "campaign_names": {
    "en": "Campaign Name",
    "ru": "Название кампании"
  },
  "campaign_redeems_count_for_user": "1",
  "expiration_date": "2019-12-31",
  "project_id": "12345",
  "redeems_count": "10",
  "redeems_count_for_user": "1",
  "subscription_coupon": null,
  "virtual_currency_amount": "100"
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"campaign_code":"sample_campaign","project_id":"12345","campaign_names":{"en":"Campaign Name","ru":"Название кампании"},"expiration_date":"2019-12-31","redeems_count":"10","redeems_count_for_user":"1","campaign_redeems_count_for_user":"1","virtual_currency_amount":"100","subscription_coupon":null}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"campaign_code":"sample_campaign","project_id":"12345","campaign_names":{"en":"Campaign Name","ru":"Название кампании"},"expiration_date":"2019-12-31","redeems_count":"10","redeems_count_for_user":"1","campaign_redeems_count_for_user":"1","virtual_currency_amount":"100","subscription_coupon":null}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"campaign_code\":\"sample_campaign\",\"project_id\":\"12345\",\"campaign_names\":{\"en\":\"Campaign Name\",\"ru\":\"Название кампании\"},\"expiration_date\":\"2019-12-31\",\"redeems_count\":\"10\",\"redeems_count_for_user\":\"1\",\"campaign_redeems_count_for_user\":\"1\",\"virtual_currency_amount\":\"100\",\"subscription_coupon\":null}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"campaign_code\":\"sample_campaign\",\"project_id\":\"12345\",\"campaign_names\":{\"en\":\"Campaign Name\",\"ru\":\"Название кампании\"},\"expiration_date\":\"2019-12-31\",\"redeems_count\":\"10\",\"redeems_count_for_user\":\"1\",\"campaign_redeems_count_for_user\":\"1\",\"virtual_currency_amount\":\"100\",\"subscription_coupon\":null}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/merchants/{merchant_id}/coupon_promotions", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"campaign_code\":\"sample_campaign\",\"project_id\":\"12345\",\"campaign_names\":{\"en\":\"Campaign Name\",\"ru\":\"Название кампании\"},\"expiration_date\":\"2019-12-31\",\"redeems_count\":\"10\",\"redeems_count_for_user\":\"1\",\"campaign_redeems_count_for_user\":\"1\",\"virtual_currency_amount\":\"100\",\"subscription_coupon\":null}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"campaign_code\":\"sample_campaign\",\"project_id\":\"12345\",\"campaign_names\":{\"en\":\"Campaign Name\",\"ru\":\"Название кампании\"},\"expiration_date\":\"2019-12-31\",\"redeems_count\":\"10\",\"redeems_count_for_user\":\"1\",\"campaign_redeems_count_for_user\":\"1\",\"virtual_currency_amount\":\"100\",\"subscription_coupon\":null}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "campaign_code": "sample_campaign",
  "project_id": "12345",
  "campaign_names": {
    "en": "Campaign Name",
    "ru": "Название кампании"
  },
  "expiration_date": "2019-12-31",
  "redeems_count": "10",
  "redeems_count_for_user": "1",
  "campaign_redeems_count_for_user": "1",
  "virtual_currency_amount": "100",
  "subscription_coupon": null
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}
{
  "id": 9134
}

Add Coupon to Campaign

Add a coupon code to a coupon campaign.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons

ParameterTypeDescription
merchant_id
integerMerchant ID. Required.
campaign_id
integerCampaign ID. Required.
coupon_code
stringCoupon code. Required.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "coupon_code": "34bryrb3"
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"coupon_code":"34bryrb3"}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"coupon_code":"34bryrb3"}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"coupon_code\":\"34bryrb3\"}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"coupon_code\":\"34bryrb3\"}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"coupon_code\":\"34bryrb3\"}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"coupon_code\":\"34bryrb3\"}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "coupon_code": "34bryrb3"
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/coupon_promotions/{campaign_id}/coupons");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Attach Campaign to Promotion

Attach a coupon campaign to a specific promotion.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons

ParameterTypeDescription
merchant_id
integerMerchant ID. Required.
promotion_id
integerPromotion ID. Required.
campaigns
array of integersArray of campaigns IDs. Required.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "campaigns": [
    9135
  ]
}
curl --request PUT \
  --url 'https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234' \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"campaigns":[9135]}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"campaigns":[9135]}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setQuery(new http\QueryString(array(
  'campaigns' => '1234'
)));

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"campaigns\":[9135]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"campaigns\":[9135]}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"campaigns\":[9135]}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"campaigns\":[9135]}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "campaigns": [
    9135
  ]
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/coupons?campaigns=1234");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Promotions

Create Promotion

Create a new promotion.

HTTP REQUEST

POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions

ParameterTypeDescription
merchant_id
integerMerchant ID.
technical_name
stringTechnical name of the promotion.
label
array of stringsArray of localized labels to show in the payment UI.
name
array of stringsArray of localized promotion names.
description
array of stringsArray of localized promotion descriptions.
project_id
integerProject ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
POST https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions

Headers:
Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "скидка 30%"
  },
  "project_id": 12345,
  "technical_name": "Sale promotion"
}
curl --request POST \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"name":{"en":"30% discount","ru":"скидка 30%"},"description":{"en":"Promotion with 30% discount","ru":"Акция со скидкой 30%"},"label":{"en":"30%","ru":"30%"},"technical_name":"Sale promotion","project_id":12345}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"name":{"en":"30% discount","ru":"скидка 30%"},"description":{"en":"Promotion with 30% discount","ru":"Акция со скидкой 30%"},"label":{"en":"30%","ru":"30%"},"technical_name":"Sale promotion","project_id":12345}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions');
$request->setRequestMethod('POST');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions");
var request = new RestRequest(Method.POST);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"name\":{\"en\":\"30% discount\",\"ru\":\"скидка 30%\"},\"description\":{\"en\":\"Promotion with 30% discount\",\"ru\":\"Акция со скидкой 30%\"},\"label\":{\"en\":\"30%\",\"ru\":\"30%\"},\"technical_name\":\"Sale promotion\",\"project_id\":12345}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"name\":{\"en\":\"30% discount\",\"ru\":\"скидка 30%\"},\"description\":{\"en\":\"Promotion with 30% discount\",\"ru\":\"Акция со скидкой 30%\"},\"label\":{\"en\":\"30%\",\"ru\":\"30%\"},\"technical_name\":\"Sale promotion\",\"project_id\":12345}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("POST", "/merchant/v2/merchants/{merchant_id}/promotions", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"name\":{\"en\":\"30% discount\",\"ru\":\"скидка 30%\"},\"description\":{\"en\":\"Promotion with 30% discount\",\"ru\":\"Акция со скидкой 30%\"},\"label\":{\"en\":\"30%\",\"ru\":\"30%\"},\"technical_name\":\"Sale promotion\",\"project_id\":12345}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"name\":{\"en\":\"30% discount\",\"ru\":\"скидка 30%\"},\"description\":{\"en\":\"Promotion with 30% discount\",\"ru\":\"Акция со скидкой 30%\"},\"label\":{\"en\":\"30%\",\"ru\":\"30%\"},\"technical_name\":\"Sale promotion\",\"project_id\":12345}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions")
  .post(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "name": {
    "en": "30% discount",
    "ru": "скидка 30%"
  },
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "technical_name": "Sale promotion",
  "project_id": 12345
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}
{
  "id": 17890
}

Get Promotion

Retrieves a promotion.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/ \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}
{
  "description": {
    "en": "Promotion with 30% discount",
    "ru": "Акция со скидкой 30%"
  },
  "enabled": false,
  "id": 17890,
  "label": {
    "en": "30%",
    "ru": "30%"
  },
  "name": {
    "en": "30% discount",
    "ru": "Скидка 30%"
  },
  "project_id": 40544,
  "read_only": false,
  "show_banner": true,
  "technical_name": "Sale promotion"
}

Update Promotion

Updates a promotion. If the promotion is read-only (read_only = true), you are not allowed to change "project_id" parameter.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
technical_name
stringTechnical name of the promotion.
label
array of stringsArray of localized labels to show in the payment UI.
name
array of stringsArray of localized promotion names.
description
array of stringsArray of localized promotion descriptions.
project_id
integerProject ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/

Headers:
Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "description": {
    "en": "Promotion with 5% discount",
    "ru": "Акция со скидкой 5%"
  },
  "label": {
    "en": "5%",
    "ru": "5%"
  },
  "name": {
    "en": "5% discount",
    "ru": "скидка 5%"
  },
  "project_id": 40544,
  "technical_name": "Sale promotion"
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/ \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"description":{"en":"Promotion with 5% discount","ru":"Акция со скидкой 5%"},"label":{"en":"5%","ru":"5%"},"name":{"en":"5% discount","ru":"скидка 5%"},"technical_name":"Sale promotion","project_id":40544}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"description":{"en":"Promotion with 5% discount","ru":"Акция со скидкой 5%"},"label":{"en":"5%","ru":"5%"},"name":{"en":"5% discount","ru":"скидка 5%"},"technical_name":"Sale promotion","project_id":40544}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"description\":{\"en\":\"Promotion with 5% discount\",\"ru\":\"Акция со скидкой 5%\"},\"label\":{\"en\":\"5%\",\"ru\":\"5%\"},\"name\":{\"en\":\"5% discount\",\"ru\":\"скидка 5%\"},\"technical_name\":\"Sale promotion\",\"project_id\":40544}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"description\":{\"en\":\"Promotion with 5% discount\",\"ru\":\"Акция со скидкой 5%\"},\"label\":{\"en\":\"5%\",\"ru\":\"5%\"},\"name\":{\"en\":\"5% discount\",\"ru\":\"скидка 5%\"},\"technical_name\":\"Sale promotion\",\"project_id\":40544}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"description\":{\"en\":\"Promotion with 5% discount\",\"ru\":\"Акция со скидкой 5%\"},\"label\":{\"en\":\"5%\",\"ru\":\"5%\"},\"name\":{\"en\":\"5% discount\",\"ru\":\"скидка 5%\"},\"technical_name\":\"Sale promotion\",\"project_id\":40544}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"description\":{\"en\":\"Promotion with 5% discount\",\"ru\":\"Акция со скидкой 5%\"},\"label\":{\"en\":\"5%\",\"ru\":\"5%\"},\"name\":{\"en\":\"5% discount\",\"ru\":\"скидка 5%\"},\"technical_name\":\"Sale promotion\",\"project_id\":40544}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "description": {
    "en": "Promotion with 5% discount",
    "ru": "Акция со скидкой 5%"
  },
  "label": {
    "en": "5%",
    "ru": "5%"
  },
  "name": {
    "en": "5% discount",
    "ru": "скидка 5%"
  },
  "technical_name": "Sale promotion",
  "project_id": 40544
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Review Promotion

You need to review a promotion before activating it. This method returns the list of errors, if any.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/review");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]
[
  {
    "component": "rewards",
    "message": "Please select a reward"
  }
]

Toggle Promotion

Toggles the status of a promotion from enabled to disabled and vice versa.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle');
$request->setRequestMethod('PUT');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle")
  .put(null)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify(false);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/toggle");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Delete Promotion

Deletes a promotion. You can only delete promotions with enabled = false.

HTTP REQUEST

DELETE https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
DELETE https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request DELETE \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/ \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/');
$request->setRequestMethod('DELETE');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
var request = new RestRequest(Method.DELETE);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("DELETE", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Delete.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/")
  .delete(null)
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("DELETE", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Promotions List

List all promotions.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions

ParameterTypeDescription
merchant_id
integerMerchant ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions

Headers:
Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]
[
  {
    "datetime": {
      "from": "2020-02-02T00:00:00+04:00",
      "to": "-0001-11-30T01:28:41+04:00"
    },
    "enabled": true,
    "id": 17840,
    "is_active": true,
    "is_infinite": false,
    "project": {
      "id": 12345,
      "localized_name": "Christmas sale"
    },
    "read_only": false,
    "technical_name": "christmas"
  },
  {
    "datetime": null,
    "enabled": false,
    "id": 17891,
    "is_active": false,
    "is_infinite": true,
    "project": {
      "id": 12345,
      "localized_name": "30% discount"
    },
    "read_only": false,
    "technical_name": "Sale promotion"
  }
]

Set Subject

Sets the subject of a promotion. If the promotion is read-only (read_only = true), you cannot update the subject. The subject can take the following values: 'purchase', or 'items', or 'packages'.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
purchase
booleanWhether the promotion applies to the whole purchase.
items
arrayArray of virtual items that the promotion applies to.
items.sku
stringItem SKU.
packages
arrayArray of virtual currency packages that the promotion applies to.
subscriptions
objectSubscription plans or products that the promotion applies to.
subscriptions.plans
arrayArray of subscription plans that the promotion applies to.
subscriptions.products
arrayArray of subscription-based products that the promotion applies to.
subscriptions.max_charges_count
integerMaximum number of billings that the promotion applies to.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject

Headers:
Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "digital_contents": null,
  "items": [
    {
      "id": 163109,
      "localized_name": "t-34",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"purchase":false,"items":[{"id":163109,"sku":"1234","localized_name":"t-34"}],"packages":null,"subscriptions":null,"digital_contents":null}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"purchase":false,"items":[{"id":163109,"sku":"1234","localized_name":"t-34"}],"packages":null,"subscriptions":null,"digital_contents":null}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"purchase\":false,\"items\":[{\"id\":163109,\"sku\":\"1234\",\"localized_name\":\"t-34\"}],\"packages\":null,\"subscriptions\":null,\"digital_contents\":null}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"purchase\":false,\"items\":[{\"id\":163109,\"sku\":\"1234\",\"localized_name\":\"t-34\"}],\"packages\":null,\"subscriptions\":null,\"digital_contents\":null}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"purchase\":false,\"items\":[{\"id\":163109,\"sku\":\"1234\",\"localized_name\":\"t-34\"}],\"packages\":null,\"subscriptions\":null,\"digital_contents\":null}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"purchase\":false,\"items\":[{\"id\":163109,\"sku\":\"1234\",\"localized_name\":\"t-34\"}],\"packages\":null,\"subscriptions\":null,\"digital_contents\":null}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "purchase": false,
  "items": [
    {
      "id": 163109,
      "sku": "1234",
      "localized_name": "t-34"
    }
  ],
  "packages": null,
  "subscriptions": null,
  "digital_contents": null
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Subject

Gets information on the subject of a promotion.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/subject");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}
{
  "digital_contents": null,
  "id": 178,
  "items": [
    {
      "id": 1609,
      "localized_name": "T-34-3",
      "sku": "1234"
    }
  ],
  "packages": null,
  "purchase": false,
  "subscriptions": null
}

Set Payment Systems

Sets payment systems supported for a promotion. If the list is empty, the promotion will apply to all payment systems. If the promotion is read-only (read_only = true), you cannot call this method.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
payment_systems
arrayPayment systems (array).
id
integerPayment system ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "payment_systems": [
    {
      "id": 24,
      "name": "PayPal"
    }
  ]
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"payment_systems":[{"id":24,"name":"PayPal"}]}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"payment_systems":[{"id":24,"name":"PayPal"}]}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"payment_systems\":[{\"id\":24,\"name\":\"PayPal\"}]}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"payment_systems\":[{\"id\":24,\"name\":\"PayPal\"}]}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"payment_systems\":[{\"id\":24,\"name\":\"PayPal\"}]}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"payment_systems\":[{\"id\":24,\"name\":\"PayPal\"}]}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "payment_systems": [
    {
      "id": 24,
      "name": "PayPal"
    }
  ]
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Payment Systems

Gets payment systems supported for a promotion. If the list is empty, the promotion will apply to all payment systems.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/payment_systems");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}
{
  "id": 17840,
  "payment_systems": [
    {
      "id": 27,
      "name": "Yandex.Money"
    }
  ]
}

Set Rewards

Sets the rewards for a promotion. If the promotion is read-only (read_only = true), you cannot update the rewards.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
purchase
objectSet the reward for the whole purchase.
purchase.discount_percent
floatDiscount percentage.
package
objectSet the reward for a virtual currency package.
package.bonus_percent
floatReward as a percentage of the package amount.
package.bonus_amount
floatReward as an absolute quantity of the virtual currency.
item
objectSet the reward for specific virtual items.
item.discount
arrayDiscounts for specific virtual items.
item.discount[].sku
stringItem SKU.
item.discount[].discount_percent
floatDiscount percentage.
item.discount[].max_amount
integerMaximum number of items to apply the promotion to.
item.bonus
arrayExtra virtual items given as a bonus.
item.bonus[].sku
stringItem SKU.
item.bonus[].amount
integerNumber of virtual items given as a bonus.
subscription
objectSets the reward for a subscription.
subscription.trial_days
integerTrial period in days.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "item": {
    "bonus": [
      {
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"purchase":{"discount_percent":10},"package":{"bonus_percent":5,"bonus_amount":5},"item":{"discount":[{"sku":"1234","max_amount":10,"discount_percent":5}],"bonus":[{"sku":"1234","quantity":2}]},"subscription":{"trial_days":30}}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"purchase":{"discount_percent":10},"package":{"bonus_percent":5,"bonus_amount":5},"item":{"discount":[{"sku":"1234","max_amount":10,"discount_percent":5}],"bonus":[{"sku":"1234","quantity":2}]},"subscription":{"trial_days":30}}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"purchase\":{\"discount_percent\":10},\"package\":{\"bonus_percent\":5,\"bonus_amount\":5},\"item\":{\"discount\":[{\"sku\":\"1234\",\"max_amount\":10,\"discount_percent\":5}],\"bonus\":[{\"sku\":\"1234\",\"quantity\":2}]},\"subscription\":{\"trial_days\":30}}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

payload = "{\"purchase\":{\"discount_percent\":10},\"package\":{\"bonus_percent\":5,\"bonus_amount\":5},\"item\":{\"discount\":[{\"sku\":\"1234\",\"max_amount\":10,\"discount_percent\":5}],\"bonus\":[{\"sku\":\"1234\",\"quantity\":2}]},\"subscription\":{\"trial_days\":30}}"

headers = {
    'content-type': "application/json",
    'authorization': "Basic <your_authorization_basic_key>"
    }

conn.request("PUT", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards", payload, headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Put.new(url)
request["content-type"] = 'application/json'
request["authorization"] = 'Basic <your_authorization_basic_key>'
request.body = "{\"purchase\":{\"discount_percent\":10},\"package\":{\"bonus_percent\":5,\"bonus_amount\":5},\"item\":{\"discount\":[{\"sku\":\"1234\",\"max_amount\":10,\"discount_percent\":5}],\"bonus\":[{\"sku\":\"1234\",\"quantity\":2}]},\"subscription\":{\"trial_days\":30}}"

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\"purchase\":{\"discount_percent\":10},\"package\":{\"bonus_percent\":5,\"bonus_amount\":5},\"item\":{\"discount\":[{\"sku\":\"1234\",\"max_amount\":10,\"discount_percent\":5}],\"bonus\":[{\"sku\":\"1234\",\"quantity\":2}]},\"subscription\":{\"trial_days\":30}}");
Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards")
  .put(body)
  .addHeader("content-type", "application/json")
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = JSON.stringify({
  "purchase": {
    "discount_percent": 10
  },
  "package": {
    "bonus_percent": 5,
    "bonus_amount": 5
  },
  "item": {
    "discount": [
      {
        "sku": "1234",
        "max_amount": 10,
        "discount_percent": 5
      }
    ],
    "bonus": [
      {
        "sku": "1234",
        "quantity": 2
      }
    ]
  },
  "subscription": {
    "trial_days": 30
  }
});

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("PUT", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response


Get Rewards

Gets the list of rewards associated with a promotion.

HTTP REQUEST

GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
GET https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards

Headers:
  Authorization: Basic <your_authorization_basic_key>
curl --request GET \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards \
  --header 'authorization: Basic <your_authorization_basic_key>'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards');
$request->setRequestMethod('GET');
$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards");
var request = new RestRequest(Method.GET);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
IRestResponse response = client.Execute(request);
import http.client

conn = http.client.HTTPSConnection("api.xsolla.com")

headers = { 'authorization': "Basic <your_authorization_basic_key>" }

conn.request("GET", "/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
require 'uri'
require 'net/http'

url = URI("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(url)
request["authorization"] = 'Basic <your_authorization_basic_key>'

response = http.request(request)
puts response.read_body
OkHttpClient client = new OkHttpClient();

Request request = new Request.Builder()
  .url("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards")
  .get()
  .addHeader("authorization", "Basic <your_authorization_basic_key>")
  .build();

Response response = client.newCall(request).execute();
var data = null;

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("GET", "https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/rewards");
xhr.setRequestHeader("authorization", "Basic <your_authorization_basic_key>");

xhr.send(data);
Response
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}
{
  "id": 17840,
  "item": {
    "bonus": [
      {
        "id": 163109,
        "localized_name": "T-34-3",
        "quantity": 2,
        "sku": "1234"
      }
    ],
    "discount": [
      {
        "discount_percent": 5,
        "localized_name": "T-34-3",
        "max_amount": 10,
        "sku": "1234"
      }
    ]
  },
  "package": {
    "bonus_amount": 5,
    "bonus_percent": 5
  },
  "purchase": {
    "discount_percent": 10
  },
  "subscription": {
    "trial_days": 30
  }
}

Set Validity Periods

Sets date/time ranges when a promotion is valid. If the promotion is read-only (read_only = true), you cannot edit existing periods, but you can add new ones.

HTTP REQUEST

PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/periods

ParameterTypeDescription
merchant_id
integerMerchant ID.
promotion_id
integerPromotion ID.
periods
arrayDate/time ranges (array).
from
datetimePeriod start.
to
datetimePeriod end.
Copy
Full screen
http
  • http
  • curl
  • php
  • C#
  • python
  • ruby
  • java
  • js
Request
PUT https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/periods

Headers:
  Authorization: Basic <your_authorization_basic_key>
Content-Type: application/json

Body:
  {
  "periods": [
    {
      "from": "2019-03-01T00:00:00+04:00",
      "to": "2019-04-01T00:00:00+04:00"
    }
  ]
}
curl --request PUT \
  --url https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/periods \
  --header 'authorization: Basic <your_authorization_basic_key>' \
  --header 'content-type: application/json' \
  --data '{"periods":[{"from":"2019-03-01T00:00:00+04:00","to":"2019-04-01T00:00:00+04:00"}]}'
<?php

$client = new http\Client;
$request = new http\Client\Request;

$body = new http\Message\Body;
$body->append('{"periods":[{"from":"2019-03-01T00:00:00+04:00","to":"2019-04-01T00:00:00+04:00"}]}');

$request->setRequestUrl('https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/periods');
$request->setRequestMethod('PUT');
$request->setBody($body);

$request->setHeaders(array(
  'authorization' => 'Basic <your_authorization_basic_key>',
  'content-type' => 'application/json'
));

$client->enqueue($request)->send();
$response = $client->getResponse();

echo $response->getBody();
var client = new RestClient("https://api.xsolla.com/merchant/v2/merchants/{merchant_id}/promotions/{promotion_id}/periods");
var request = new RestRequest(Method.PUT);
request.AddHeader("authorization", "Basic <your_authorization_basic_key>");
request.AddHeader("content-type", "application/json");
request.AddParameter("application/json", "{\"periods\":[{\"from\":\"2019-03-01T00:00:00+04:00\",\"to\":\"2019-04-01T00:00:00+04:00\"}]}", ParameterType.RequestBody