Skip to content
Skip to Content
DevelopersAPI referenceRules

Create a rule

POST
/v1/rules

A rule has one event (its trigger), a condition tree and a list of actions, as in Karakeep. When the event happens to an item and the condition holds for the item as it is then, the actions run, in order. Rules run in the order they were made, and each one sees what the ones before it did. Changes made by rules send no webhooks and trigger no other rules. Rules do not touch items that already exist. A user can have at most 20 rules. See docs/RULES.md.

Authorization

bearer
headerAuthorizationBearer <token>

A personal API key (ga_…), sent as Authorization: Bearer ga_…. A key gets 403 on a resource it has no access to, and on anything that changes data without write access.

Request Body

application/json
  1. body
name*string
Lengthlength <= 80
description?|
Lengthlength <= 280
enabled?boolean
Defaulttrue
event*

What triggers a rule. tag is required for tagAdded and tagRemoved; list_ids (at least one, all the user's own lists) for addedToList and removedFromList. Other fields are ignored.

condition*

One node of a condition tree (at most 50 nodes, 10 levels). and and or hold conditions (at least one). urlContains, urlDoesNotContain, titleContains and titleDoesNotContain take str and compare case-sensitively; urlDoesNotContain is false for an item that is not a link. bookmarkTypeIs takes item_type. hasTag takes tag and sees the user's tags and the AI's. search is Trova's own: query is a search of operators only (see docs/SEARCH.md).

actions*array<>
Items1 <= items <= 10

Response Body

The new rule

application/json
  1. response
id*string
name*string
description*string|null
enabled*boolean
event*

What triggers a rule. tag is required for tagAdded and tagRemoved; list_ids (at least one, all the user's own lists) for addedToList and removedFromList. Other fields are ignored.

condition*

One node of a condition tree (at most 50 nodes, 10 levels). and and or hold conditions (at least one). urlContains, urlDoesNotContain, titleContains and titleDoesNotContain take str and compare case-sensitively; urlDoesNotContain is false for an item that is not a link. bookmarkTypeIs takes item_type. hasTag takes tag and sees the user's tags and the AI's. search is Trova's own: query is a search of operators only (see docs/SEARCH.md).

actions*array<>
applied_count*integer

Times the rule changed an item

last_applied_at*|
Formatdate-time
created_at*string
Formatdate-time
updated_at*string
Formatdate-time
Example Request
curl -X POST 'https://example.com/v1/rules' \  -H 'Content-Type: application/json' \  -d '{  "name": "string",  "event": {    "type": "bookmarkAdded"  },  "condition": {    "type": "alwaysTrue"  },  "actions": [    {      "type": "addTag"    }  ]}'
Example Response
{  "id": "string",  "name": "string",  "description": "string",  "enabled": true,  "event": {    "type": "bookmarkAdded",    "tag": "string",    "list_ids": [      "string"    ]  },  "condition": {    "type": "alwaysTrue",    "str": "string",    "tag": "string",    "item_type": "link",    "query": "string",    "conditions": [      {}    ]  },  "actions": [    {      "type": "addTag",      "tag": "string",      "list_id": "string"    }  ],  "applied_count": 0,  "last_applied_at": "2019-08-24T14:15:22Z",  "created_at": "2019-08-24T14:15:22Z",  "updated_at": "2019-08-24T14:15:22Z"}