{"info":{"_postman_id":"e28f6e64-c8e0-f2ac-67be-58854e4ca203","name":"Freeplay API","description":"<html><head></head><body><h2 id=\"introduction\">Introduction</h2>\n<p>This API offers the possibility to create Freeplay tokens to selected users.</p>\n<h2 id=\"request\">Request</h2>\n<p>Our server will use JSON as the request body format to be consistent with responses. </p>\n<h2 id=\"response-format\">Response format</h2>\n<p>Responses will always be in JSON format.</p>\n<h2 id=\"authentication\">Authentication</h2>\n<p>All endpoints in this API requires authentication in order to be accessed.</p>\n<p>Authentication is HMAC-signature based.\nUpon registering as a partner with Colossus Bets, you'll receive an <code>api_auth_key</code> and an <code>api_auth_secret</code>.</p>\n<p>Please follow the steps below to sign your requests.</p>\n<h3 id=\"request-headers\">Request Headers</h3>\n<p>There are some important headers that needs to be provided in all your requests:</p>\n<ul>\n<li><p>Date: this is the HTTP timestamp of the request in the RFC 1123/2822 Internet Standard. For security reasons, our API will reject the request when the HTTP timestamp is too much in the past (currently set to 15 minutes max).\nValue example: <code>Mon, 23 Jan 1984 03:29:56 GMT</code>.</p>\n</li>\n<li><p>Authorization: this is the header that will contain the HMAC signature. The format will be <code>APIAuth-HMAC-SHA256 {{api_auth_key}}:{{signature}}</code>. You'll need to substitute <code>api_auth_key</code> and <code>signature</code>. The former will be provided by us while the latter will need to be calculated (see below in Signature Generation paragraph).</p>\n</li>\n<li><p>(Optional) Content-MD5: this is the standard header which is the Base64 encoding of the MD5 hash of the request body. It's optional in case of an empty body or a GET request.</p>\n</li>\n<li><p>(Optional) Content-Type: this is the standard header which will tell the api how to read the request body. It's optional in case of an empty body or a GET request.</p>\n</li>\n</ul>\n<h3 id=\"signature-generation\">Signature Generation</h3>\n<p>In order to calculate the signature, you'll first need to generate the <code>canonical string</code>. The format for it is the following:</p>\n<p><code>{{HTTP_METHOD}},[Content-Type],[Content-MD5],{{RequestURI}},{{Date}}</code></p>\n<ul>\n<li>HTTP_METHOD: this is the HTTP Method of the request, uppercase. Can be <code>GET, POST, DELETE</code> or any other HTTP method.</li>\n<li>RequestURI: this is the <code>path</code> part of your request URL, including the querystring parameters.</li>\n<li>Content-Type, Content-MD5 and Date: these are the same values of the 3 headers with the same name, if present.</li>\n</ul>\n<p>The elements between <code>{{ }}</code> are mandatory, while the ones between <code>[ ]</code> are optional. All commas are mandatory, even when an element is missing.</p>\n<p>Once you calculated the canonical string based on the request, you can proceed calculating the signature from it. This can be achieved with the following 2 steps:</p>\n<ol>\n<li>Calculate the SHA256 HMAC hash of the canonical string using your <code>api_auth_secret</code> (provided by us).</li>\n<li>Encode the resulting hash using Base64 encoding.</li>\n</ol>\n<h3 id=\"example\">Example</h3>\n<p>We'll now guide you through an example for a request authentication.</p>\n<p>Let's assume Colossus Bets provided you with the following details:</p>\n<div class=\"click-to-expand-wrapper is-table-wrapper\"><table>\n<thead>\n<tr>\n<th>Variable</th>\n<th>Value</th>\n</tr>\n</thead>\n<tbody>\n<tr>\n<td><code>api_auth_key</code></td>\n<td>api_key</td>\n</tr>\n<tr>\n<td><code>api_auth_secret</code></td>\n<td>api_secret</td>\n</tr>\n</tbody>\n</table>\n</div><p>Let's assume that for this test we want to call the <code>POST /F2PConsole/api/FreeToPlay/GiveTokensToUsers</code> endpoint and the body of the request will be something like:</p>\n<pre class=\"click-to-expand-wrapper is-snippet-wrapper\"><code class=\"language-json\">[\n    {\n        \"user_id\" : \"john23\",\n        \"plays\" : \"2\"\n    },\n    {\n        \"user_id\" : \"amy27\",\n        \"plays\" : \"1\"\n    },\n    {\n        \"user_id\" : \"2376890\",\n        \"plays\" : \"2\"\n    }\n]\n</code></pre>\n<p>We will then calculate the content-MD5 header, from the body (<code>y1OKcElbEvKAljAHcXtwEA==</code>) and we should compute the following canonical string: <code>POST,application/json,y1OKcElbEvKAljAHcXtwEA==,/f2pconsole/api/freetoplay/givetokenstousers,Thu, 22 Mar 2018 15:23:15 GMT</code>,  from which we can calculate the Base64 encoding of the SHA256 HMAC hash, using the <code>api_secret</code>, which give us <code>oapdEIG5iqI7a/9POrbLUuC4i2PAgQxYBKGWZYWWd6U=</code>. The final <code>Authorization</code> header will then be: <code>APIAuth-HMAC-SHA256 api_key:oapdEIG5iqI7a/9POrbLUuC4i2PAgQxYBKGWZYWWd6U=</code>.</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"1255977","collectionId":"e28f6e64-c8e0-f2ac-67be-58854e4ca203","publishedId":"6YzuD1s","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"EF5B25"},"publishDate":"2018-04-04T14:55:59.000Z"},"item":[{"name":"GiveTokensToUsers (deprecated)","event":[{"listen":"prerequest","script":{"type":"text/javascript","exec":["var ApiAuth = eval(globals.loadApiAuth);","ApiAuth.computeSignature();",""]}},{"listen":"test","script":{"type":"text/javascript","exec":["tests[\"Status code is 201\"] = responseCode.code === 201;",""]}}],"id":"f6657e34-7955-e59e-e87f-a1eba6744d8c","request":{"method":"POST","header":[{"key":"Authorization","value":"{{api_auth_sha}} {{api_auth_key}}:{{signature}}"},{"key":"Date","value":"{{time}}"},{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"},{"key":"Content-MD5","value":"{{content-MD5}}"}],"body":{"mode":"raw","raw":"[\n    {\n          \"user_id\" : \"john23\",\n          \"plays\" : \"2\"\n      },\n      {\n          \"user_id\" : \"amy27\",\n          \"plays\" : \"1\"\n      }\n]"},"url":"{{api_url}}{{api_base}}/freetoplay/givetokenstousers","description":"<h2 id=\"behavior\">Behavior:</h2>\n<p>It gives to the specified users a FreeToPlay token, containing the corresponding number of plays or it will increase the current number of plays in an already valid token if in the same <code>ApiCampaign</code>.</p>\n<p>At the moment, the first available <code>ApiCampaign</code> is used.</p>\n<p>An <code>ApiCampaign</code> can be created via the <code>FreeToPlay console access</code> provided by Colossus Bets.</p>\n<h2 id=\"parameters\">Parameters:</h2>\n<p>An array of hashes containing 2 keys: </p>\n<ul>\n<li><code>user_id</code> - the id of the user in your system (the one that Colossus receives from the user authentication/user info endpoint on your wallet)</li>\n<li><code>plays</code> - the amount of plays(nr of lines) that the user can play for free</li>\n</ul>\n","urlObject":{"path":["freetoplay","givetokenstousers"],"host":["{{api_url}}{{api_base}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"f6657e34-7955-e59e-e87f-a1eba6744d8c"},{"name":"ClaimTokens","event":[{"listen":"prerequest","script":{"id":"6b4842a9-8ff0-4f49-8ef0-f476319d43bd","exec":["var ApiAuth = eval(globals.loadApiAuth);","ApiAuth.computeSignature();",""],"type":"text/javascript"}},{"listen":"test","script":{"id":"4981b548-1093-4dba-b573-742e4a5bfded","exec":["tests[\"Status code is 201\"] = responseCode.code === 201;",""],"type":"text/javascript"}}],"id":"8e128338-a9a2-4bb2-a0bc-3bc4c4c0d8f9","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"{{api_auth_sha}} {{api_auth_key}}:{{signature}}"},{"key":"Date","value":"{{time}}"},{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"},{"key":"Content-MD5","value":"{{content-MD5}}"}],"body":{"mode":"raw","raw":"{\n  \"campaign_id\": 502,\n  \"users\": [\n    {\n          \"user_id\" : \"nandobermejo\",\n          \"plays\" : \"2\"\n      }\n  ]\n}"},"url":"{{api_url}}/api/freetoplay/claimtokens","description":"<h2 id=\"behavior\">Behavior:</h2>\n<p>It gives to the specified users a FreeToPlay token, containing the corresponding number of plays or it will increase the current number of plays in an already valid token if in the same chosen campaign.</p>\n<p>An <code>ApiCampaign</code> can be created via the <code>FreeToPlay console access</code> provided by Colossus Bets.</p>\n<h2 id=\"parameters\">Parameters:</h2>\n<ul>\n<li><code>campaign_id</code> - the id of the created campaign in the console</li>\n<li><code>users</code> - an array of hashes (an empty array is valid as well, no tokens are assigned in that case) containing:<ul>\n<li><code>user_id</code> - the id of the user in your system (the one that Colossus received or will receive from the user authentication/user info endpoint on your wallet)</li>\n<li><code>plays</code> - the amount of plays(nr of lines) that the user can play for free</li>\n</ul>\n</li>\n</ul>\n<h2 id=\"responses\">Responses</h2>\n<p>Success responses:</p>\n<ul>\n<li><code>201 created</code> All tokens have been assigned.</li>\n</ul>\n<p>Client error responses: (some of them are accompanied by a readable error message)</p>\n<ul>\n<li><code>400 bad request</code> In any of the following cases: <ul>\n<li>The body is missing either the campaign id or the list of users, or any of the users in the list is missing either\nthe customer_id or the number of plays.</li>\n<li>The campaign is not active.</li>\n<li>The campaign has reached its limit of assignable tokens.</li>\n</ul>\n</li>\n<li><code>401 unauthorized</code> APIauth authentication failed or wrong merchant credentials</li>\n<li><code>404 not found</code> The campaign was not found.</li>\n</ul>\n<p>Server error responses:</p>\n<ul>\n<li><code>500 internal server error</code> Usually this means the partner configuration is absent, in this case please contact us.</li>\n</ul>\n","urlObject":{"path":["api","freetoplay","claimtokens"],"host":["{{api_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"8e128338-a9a2-4bb2-a0bc-3bc4c4c0d8f9"},{"name":"Badges","event":[{"listen":"prerequest","script":{"type":"text/javascript","exec":["var ApiAuth = eval(globals.loadApiAuth);","ApiAuth.computeSignature();",""]}},{"listen":"test","script":{"type":"text/javascript","exec":["tests[\"Status code is 201\"] = responseCode.code === 201;",""]}}],"id":"45fb9db1-4296-4196-9b51-c672410a48da","request":{"method":"GET","header":[{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"}],"body":{"mode":"raw","raw":"{\n  \"campaign_id\": 1,\n  \"users\": [\n    {\n          \"user_id\" : \"john23\",\n          \"plays\" : \"2\"\n      },\n      {\n          \"user_id\" : \"amy27\",\n          \"plays\" : \"1\"\n      },\n      {\n          \"user_id\" : \"2376890\",\n          \"plays\" : \"2\"\n      }\n  ]\n}"},"url":"{{microsite_api_url}}/api/users/{{id}}/badges/","description":"<h2 id=\"behavior\">Behavior:</h2>\n<p>It gives the amount of plays (number of lines) that the user can play for free. It can be used to show the number of free plays available for a customer outside of the iframe.</p>\n<h2 id=\"parameters\">Parameters:</h2>\n<ul>\n<li><code>id</code> - the id of the user in your system (the one that Colossus receives from the user authentication/user info endpoint on your wallet)</li>\n</ul>\n<h2 id=\"responses\">Responses</h2>\n<p>Success responses:</p>\n<ul>\n<li><code>200 OK</code></li>\n<li><code>{freeplays: 3}</code></li>\n</ul>\n<p>Error responses:</p>\n<ul>\n<li><code>404 Not Found</code></li>\n<li><code>{code: \"COULDN'T FIND USER\"}</code></li>\n</ul>\n","urlObject":{"path":["api","users","{{id}}","badges",""],"host":["{{microsite_api_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"45fb9db1-4296-4196-9b51-c672410a48da"},{"name":"GetCampaigns","event":[{"listen":"prerequest","script":{"id":"fe287a81-8b0b-4539-8469-aeca4f63d3de","exec":["var ApiAuth = eval(globals.loadApiAuth);","ApiAuth.computeSignature();"],"type":"text/javascript"}},{"listen":"test","script":{"id":"df952590-aad3-4043-bbb7-1b7716384634","exec":["tests[\"Status code is 201\"] = responseCode.code === 201;",""],"type":"text/javascript"}}],"id":"28515d03-2b4b-40f3-8b87-d0ad650928b2","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Authorization","value":"{{api_auth_sha}} {{api_auth_key}}:{{signature}}"},{"key":"Date","value":"{{time}}"},{"key":"Content-Type","value":"application/json"},{"key":"Accept","value":"application/json"},{"key":"Content-MD5","value":"{{content-MD5}}"}],"url":"{{api_url}}/api/freetoplay/getcampaigns","description":"<h2 id=\"behavior\">Behavior:</h2>\n<p>It gives a list of campaigns. <code>#WIP</code></p>\n","urlObject":{"path":["api","freetoplay","getcampaigns"],"host":["{{api_url}}"],"query":[],"variable":[]}},"response":[],"_postman_id":"28515d03-2b4b-40f3-8b87-d0ad650928b2"}]}