Upsert currency sale for user
Definition
This API endpoint allows you to create or update a currency sale for a given user in real time.
Request
GET https://api.inbrain.ai/panelist-api/v1/{userId}/currency-sales
Headers
Header | Description | Required |
---|---|---|
X-InBrain-Api-Key | Authentication API Key | true |
Parameters
Endpoint accepts a user id route parameter and a set of parameters in the body on the request link.
Root parameters
Parameter | Description | Required |
---|---|---|
userId | Unique user identifier | true |
externalId | Unique identifier for the sale | true |
description | Optional description for the sale | false |
startOn | Start date of the sale | true |
endOn | End date of the sale | true |
multiplier | Sale multiplier | true |
lockedUntil | date | Date until the currency sale is locked read more |
Examples
- cURL
- C#
- Node.js
curl \
--request PUT 'https://api.inbrain.ai/panelist-api/v1/{userId}/currency-sales' \
--header 'X-InBrain-Api-Key: YOUR_API_KEY_HERE' \
--data '{
"externalId": "test",
"description": null,
"startOn": "2023-06-11T21:14:20.8835755Z",
"endOn": "2023-09-25T09:15:20.8835755Z",
"lockedUntil": "2023-08-09T12:10:20.8835755Z",
"multiplier": 3
}'
using System.Net.Http;
using System.Threading.Tasks;
var requestUrl = "https://api.inbrain.ai/panelist-api/v1/{userId}/currency-sales";
using (var httpClient = new HttpClient())
{
var requestMessage = new HttpRequestMessage(HttpMethod.Put, requestUrl);
requestMessage.Headers.Add("X-InBrain-Api-Key", "YOUR_API_KEY_HERE");
requestMessage.Content = new StringContent("{\r\n \"externalId\": \"test\",\r\n \"description\": null,\r\n \"startOn\": \"2023-06-11T21:14:20.8835755Z\",\r\n \"endOn\": \"2023-09-25T09:15:20.8835755Z\",\r\n \"lockedUntil\": \"2023-08-09T12:10:20.8835755Z\",\r\n \"multiplier\": 3\r\n}", null, "application/json");
var response = await httpClient.SendAsync(requestMessage);
// process the response
}
const https = require('https');
var options = {
'method': 'PUT',
'hostname': 'api.inbrain.ai',
'path': '/panelist-api/v1/{userId}/currency-sales',
'headers': {
'Content-Type': 'application/json',
'x-inbrain-api-key': 'YOUR_API_KEY_HERE'
},
'maxRedirects': 20
};
var req = https.request(options, function (res) {
var chunks = [];
res.on("data", function (chunk) {
chunks.push(chunk);
});
res.on("end", function (chunk) {
var body = Buffer.concat(chunks);
console.log(body.toString());
});
res.on("error", function (error) {
console.error(error);
});
});
var postData = JSON.stringify({
"externalId": "test",
"description": null,
"startOn": "2023-06-11T21:14:20.8835755Z",
"endOn": "2023-09-25T09:15:20.8835755Z",
"lockedUntil": "2023-08-09T12:10:20.8835755Z",
"multiplier": 3
});
req.write(postData);
req.end();
Response
Response codes
Code | Description | Reason |
---|---|---|
200 | Success | |
400 | Bad Request | Some of the request parameters are missing or invalid |
401 | Unauthorized | Invalid API Key |
409 | Conflict | Currency sale is locked |
429 | Too Many Requests | Too many requests in a given amount of time |
500 | Internal Server Error | Server error occured while processing the request |
Success model
Successful response is a 200 OK without a body.
Error model
Error response is a JSON object with the properties given below.
Property | Type | Description | Required |
---|---|---|---|
code | string | API error code | true |
description | string | API error description | true |
messages | string[] | Error messages providing further error details | false |
Examples
- Success (200)
- Bad Request (400)
- Internal Server Error (500)
{
"code": "C1001",
"description": "One or more validation errors occurred",
"messages": [
"'endOn' is required parameter"
]
}
{
"code": "C1148",
"description": "Internal server error"
}