Take a unit from a person for something
curl --request POST \
--url https://api.getlurk.com/v1/units/spend \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"user": "ana@example.com",
"unit": "points",
"amount": 100,
"reason": "Free coffee",
"reference": "redeem-5521"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user: 'ana@example.com',
unit: 'points',
amount: 100,
reason: 'Free coffee',
reference: 'redeem-5521'
})
};
fetch('https://api.getlurk.com/v1/units/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.getlurk.com/v1/units/spend"
payload = {
"user": "ana@example.com",
"unit": "points",
"amount": 100,
"reason": "Free coffee",
"reference": "redeem-5521"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "act_01m6p4qj0gev1rx6h7tqtbhj53",
"user": {
"id": "usr_01m2ayvr9gf8e89t8f5cbx71b0",
"external_id": "ana@example.com"
},
"unit": "points",
"amount": 100,
"balance_after": 69,
"reference": "redeem-5521"
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}Units
Take a unit from a person for something
Takes an amount of a unit from a person, all or nothing (insufficient_balance). The unit needs spendable on. A reference is used once per unit (reference_used). Unknown person or unit: not_found. Owners and admins, or a project key; never an agent. Spending
POST
/
v1
/
units
/
spend
Take a unit from a person for something
curl --request POST \
--url https://api.getlurk.com/v1/units/spend \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"user": "ana@example.com",
"unit": "points",
"amount": 100,
"reason": "Free coffee",
"reference": "redeem-5521"
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
user: 'ana@example.com',
unit: 'points',
amount: 100,
reason: 'Free coffee',
reference: 'redeem-5521'
})
};
fetch('https://api.getlurk.com/v1/units/spend', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.getlurk.com/v1/units/spend"
payload = {
"user": "ana@example.com",
"unit": "points",
"amount": 100,
"reason": "Free coffee",
"reference": "redeem-5521"
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "act_01m6p4qj0gev1rx6h7tqtbhj53",
"user": {
"id": "usr_01m2ayvr9gf8e89t8f5cbx71b0",
"external_id": "ana@example.com"
},
"unit": "points",
"amount": 100,
"balance_after": 69,
"reference": "redeem-5521"
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}Authorizations
Headers
Body
application/json
Response
Take a unit from a person for something