Skip to content

Commit b57b128

Browse files
authored
Merge pull request #8 from craftnote/add-webhooks
Add project tasks, messages, and webhooks endpoints to OpenAPI spec
2 parents 142ffdb + 96c6702 commit b57b128

File tree

2 files changed

+808
-14
lines changed

2 files changed

+808
-14
lines changed

README.md

+75
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,81 @@ A work time can have the following states:
231231

232232
* The `workTypeId` refers to the `workTypes` that can be accessed from the company settings.
233233

234+
## Webhooks
235+
Webhooks allow you to receive real-time notifications when events occur in your Craftnote account. When an event happens, Craftnote sends an HTTP POST request to the URL you've configured for your webhook.
236+
237+
### Webhook Payload Structure
238+
When an event occurs, Craftnote sends a JSON payload to your webhook URL with the following structure:
239+
240+
```json
241+
{
242+
"event": "resource.action",
243+
"timestamp": 1741172456,
244+
"action": "created",
245+
"resourceId": "resource-type/resource-id",
246+
"fieldPath": "$",
247+
"data": {
248+
// The complete resource data
249+
},
250+
"previousData": null
251+
}
252+
```
253+
254+
- `event`: A string in the format "resource.action" that identifies what happened
255+
- `timestamp`: Unix timestamp (seconds since epoch) when the event occurred
256+
- `action`: The type of action that triggered the event (currently only "created" is supported)
257+
- `resourceId`: A string identifying the resource that was affected, in the format "resource-type/id"
258+
- `fieldPath`: Path to the field that was changed ($ represents the entire resource)
259+
- `data`: The complete current state of the resource
260+
- `previousData`: The previous state of the resource (null for creation events)
261+
262+
### Supported Events
263+
Currently, only creation events are supported for the following resources:
264+
265+
#### Project Events
266+
- `project.created`: Triggered when a new project is created
267+
268+
#### Task Events
269+
- `task.created`: Triggered when a new task is created
270+
271+
#### Chat Message Events
272+
- `message.created`: Triggered when a new chat message is posted
273+
274+
#### Time Tracking Events
275+
- `trackedTime.created`: Triggered when a new time entry is created
276+
277+
#### File Events
278+
- `file.created`: Triggered when a new file is uploaded
279+
280+
### Example Webhook Payload
281+
Here's an example of a webhook payload for a task creation event:
282+
283+
```json
284+
{
285+
"event": "task.created",
286+
"timestamp": 1741172456,
287+
"action": "created",
288+
"resourceId": "tasks/3db95e59-2be3-45e1-9858-9c56945e526a",
289+
"fieldPath": "$",
290+
"data": {
291+
"id": "3db95e59-2be3-45e1-9858-9c56945e526a",
292+
"title": "New Task",
293+
"projectId": "044337df-e9fd-48bc-8f2e-dadd6bc09629",
294+
"creatorId": "HVU9tHEyejVh8fiBfbyj99zfpjq1",
295+
"companyId": "19b8ba22-97d0-4e73-96f7-ebeb1b487525",
296+
"description": "This is a test task",
297+
"createdTimestamp": 1741172456,
298+
"assigneeId": "HVU9tHEyejVh8fiBfbyj99zfpjq1",
299+
"assignee": "McCraftFace, Crafty",
300+
"lastChangeByUser": "HVU9tHEyejVh8fiBfbyj99zfpjq1",
301+
"lastEditedTimestamp": 1741172456,
302+
"isDeleted": false
303+
},
304+
"previousData": null
305+
}
306+
```
307+
308+
The structure of the `data` field will match the corresponding resource schema as defined in the API documentation.
234309

235310
## Accessing Company Members
236311
### List all members

0 commit comments

Comments
 (0)