Create a rule as a draft
curl --request POST \
--url https://api.getlurk.com/v1/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Points for orders",
"key": "order-points",
"when": {
"event": "order.paid"
},
"if": [
{
"property": {
"name": "currency",
"equals": "USD"
}
}
],
"limit": [
{
"max": 5,
"per": "day"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Points for orders',
key: 'order-points',
when: {event: 'order.paid'},
if: [{property: {name: 'currency', equals: 'USD'}}],
limit: [{max: 5, per: 'day'}],
do: [{unit: 'points', add: {from: 'total_cents', per: 100}}]
})
};
fetch('https://api.getlurk.com/v1/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.getlurk.com/v1/rules"
payload = {
"name": "Points for orders",
"key": "order-points",
"when": { "event": "order.paid" },
"if": [{ "property": {
"name": "currency",
"equals": "USD"
} }],
"limit": [
{
"max": 5,
"per": "day"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "rule_01m2z44880ev18z457tkgkpp00",
"key": "order-points",
"name": "Points for orders",
"status": "draft",
"version": 1,
"live_version": null,
"definition": {
"when": {
"event": "order.paid"
},
"if": [
{
"property": {
"name": "currency",
"equals": "USD"
}
}
],
"limit": [
{
"max": 5,
"per": "day",
"by": "user"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
}{
"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>"
}
}{
"error": {
"status": 123,
"code": "invalid_json",
"message": "<string>",
"request_id": "<string>",
"doc_url": "<string>",
"param": "<string>",
"next_step": "<string>"
}
}Rules
Create a rule as a draft
Nothing runs until an owner or admin takes the draft live, in person. Keys and agents can create and preview rules, but saving a rule with effects (not available yet) is refused with approval_required. key defaults to a slug of the name. See Rules.
POST
/
v1
/
rules
Create a rule as a draft
curl --request POST \
--url https://api.getlurk.com/v1/rules \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--header 'Idempotency-Key: <idempotency-key>' \
--data '
{
"name": "Points for orders",
"key": "order-points",
"when": {
"event": "order.paid"
},
"if": [
{
"property": {
"name": "currency",
"equals": "USD"
}
}
],
"limit": [
{
"max": 5,
"per": "day"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
'const options = {
method: 'POST',
headers: {
'Idempotency-Key': '<idempotency-key>',
Authorization: 'Bearer <token>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'Points for orders',
key: 'order-points',
when: {event: 'order.paid'},
if: [{property: {name: 'currency', equals: 'USD'}}],
limit: [{max: 5, per: 'day'}],
do: [{unit: 'points', add: {from: 'total_cents', per: 100}}]
})
};
fetch('https://api.getlurk.com/v1/rules', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.getlurk.com/v1/rules"
payload = {
"name": "Points for orders",
"key": "order-points",
"when": { "event": "order.paid" },
"if": [{ "property": {
"name": "currency",
"equals": "USD"
} }],
"limit": [
{
"max": 5,
"per": "day"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
headers = {
"Idempotency-Key": "<idempotency-key>",
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"id": "rule_01m2z44880ev18z457tkgkpp00",
"key": "order-points",
"name": "Points for orders",
"status": "draft",
"version": 1,
"live_version": null,
"definition": {
"when": {
"event": "order.paid"
},
"if": [
{
"property": {
"name": "currency",
"equals": "USD"
}
}
],
"limit": [
{
"max": 5,
"per": "day",
"by": "user"
}
],
"do": [
{
"unit": "points",
"add": {
"from": "total_cents",
"per": 100
}
}
]
}
}{
"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>"
}
}{
"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
Create a rule as a draft