{"__v":2,"_id":"551ef4f04986f62b00a72066","category":{"__v":4,"_id":"551ef4ef4986f62b00a72038","pages":["551ef4f04986f62b00a7205d","551ef4f04986f62b00a7205e","551ef4f04986f62b00a7205f","551ef4f04986f62b00a72060","551ef4f04986f62b00a72061","551ef4f04986f62b00a72062","551ef4f04986f62b00a72063","551ef4f04986f62b00a72064","551ef4f04986f62b00a72065","551ef4f04986f62b00a72066","551ef4f04986f62b00a72067","551ef4f04986f62b00a72068","551ef4f04986f62b00a72069","551ef4f04986f62b00a7206a","551ef4f04986f62b00a7206b","551ef4f04986f62b00a7206c","5523150ae20da719000e78c2","5641731cb0dc090d00f88398","56c2761847394f0d00e2285e"],"project":"542b6018044e1e2200413772","version":"551ef4ef4986f62b00a7202e","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2014-10-22T01:34:57.891Z","from_sync":false,"order":19,"slug":"server-rest-api","title":"Server REST API"},"editedParams":true,"editedParams2":true,"parentDoc":null,"project":"542b6018044e1e2200413772","user":"542b6010044e1e220041376f","version":{"__v":10,"_id":"551ef4ef4986f62b00a7202e","forked_from":"542b6018044e1e2200413775","project":"542b6018044e1e2200413772","createdAt":"2015-04-03T20:15:43.149Z","releaseDate":"2015-04-03T20:15:43.149Z","categories":["551ef4ef4986f62b00a7202f","551ef4ef4986f62b00a72030","551ef4ef4986f62b00a72031","551ef4ef4986f62b00a72032","551ef4ef4986f62b00a72033","551ef4ef4986f62b00a72034","551ef4ef4986f62b00a72035","551ef4ef4986f62b00a72036","551ef4ef4986f62b00a72037","551ef4ef4986f62b00a72038","551ef4ef4986f62b00a72039","551ef4ef4986f62b00a7203a","551ef4ef4986f62b00a7203b","551ef4ef4986f62b00a7203c","551ef4ef4986f62b00a7203d","551ef4ef4986f62b00a7203e","55d7f1879510f00d007ec727","56b94a5a9fc0de1700b60ae9","56bd0e48ac1c5c1900b2dbe4","56d74afc3eb4dd0b0020196a","5723ab8a1f41110e003081ed","576b4dd327d6252b00085422","5792ca4369c5120e00efe023","5792ca55366dd20e004736d7","5792d30b23106419009c431b"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"2.0.0","version":"2.0"},"updates":[],"createdAt":"2014-10-22T01:15:19.777Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"examples":{"codes":[{"language":"json","code":"{\n \"purchases\": \n [{\"sku\": \"SKU123\",\n \"iso\": \"USD\",\n \"amount\": \"0.99\"}]\n}","name":""}]},"results":{"codes":[{"name":"","code":"{\"success\": true }","language":"json","status":200}]},"settings":"","auth":"never","params":[{"_id":"55e4de6b40cda60d003bad66","ref":"","in":"body","required":true,"desc":"An array of purchases, each with the properties listed below.","default":"","type":"array_mixed","name":"purchases"},{"_id":"55e4de6b40cda60d003bad65","ref":"","in":"body","required":true,"desc":"The unique identifier of the purchased item.","default":"","type":"string","name":"purchases[sku]"},{"_id":"54470527beb6320800da6f24","ref":"","in":"body","required":true,"desc":"The amount, in USD, spent purchasing the item.","default":"","type":"double","name":"purchases[amount]"},{"_id":"55e4de6b40cda60d003bad64","ref":"","in":"body","required":true,"desc":"The 3-letter [ISO 4217](http://www.currency-iso.org/dam/downloads/lists/list_one.xml) currency code. Required for correct storage and conversion of amount.","default":"","type":"string","name":"purchases[iso]"},{"_id":"55e4e7ba3325e60d007fbef1","ref":"","in":"body","required":false,"desc":"Pass true on the first run of your app if you're tracking existing non-consumable purchases. This prevents tracking the same purchases more than once if the user re-installs your app.","default":"Optional","type":"boolean","name":"existing"}],"url":"/players/:id/on_purchase"},"isReference":false,"order":11,"body":"Track a new purchase in your app. This will increment the player's amount_spent.\n[block:code]\n{\n \"codes\": [\n {\n \"code\": \"curl --include \\\\\\n --request POST \\\\\\n --header \\\"Content-Type: application/json\\\" \\\\\\n --data-binary \\\"{\\\\\\\"purchases\\\\\\\": [{\\\\\\\"sku\\\\\\\": \\\\\\\"SKU123\\\\\\\", \\\\\\\"iso\\\\\\\": \\\\\\\"USD\\\\\\\", \\\\\\\"amount\\\\\\\": \\\\\\\"0.99\\\\\\\"}]}\\\" \\\\\\n https://onesignal.com/api/v1/players/:id/on_purchase\",\n \"language\": \"shell\"\n }\n ]\n}\n[/block]","excerpt":"Track a new purchase","slug":"on_purchase","type":"post","title":"/players/:id/on_purchase"}post/players/:id/on_purchase
Track a new purchase
Definition
{{ api_url }}{{ page_api_url }}
Parameters
Body JSON
purchases:
required
array of mixed
An array of purchases, each with the properties listed below.
purchases[sku]:
required
string
The unique identifier of the purchased item.
purchases[amount]:
required
double
The amount, in USD, spent purchasing the item.
purchases[iso]:
required
string
The 3-letter [ISO 4217](http://www.currency-iso.org/dam/downloads/lists/list_one.xml) currency code. Required for correct storage and conversion of amount.
existing:
booleanOptional
Pass true on the first run of your app if you're tracking existing non-consumable purchases. This prevents tracking the same purchases more than once if the user re-installs your app.