Developers

Webhook

View as Markdown

Repsona Webhook allows you to receive event notifications and trigger actions automatically. It sends events such as task or note updates, comment additions, status changes, etc. to a specified URL (HTTP request). Can be used for integration with other services and systems.

Steps to receive a webhook

You can initiate a webhook in the following steps

  • Create a Webhook endpoint.
  • Process (implement) the request from Repsona
  • Configure the Webhook endpoint with Repsona
  • Test the Webhook endpoint
  • Verify the Webhook signature (recommended)

Create a Webhook endpoint

Create an HTTP endpoint that can accept unauthenticated Webhook requests using the POST method.

Process requests from Repsona (implementation)

The endpoint must be configured to read an Event (Event) object of the type of event notification it receives; Repsona sends the event to the Webhook endpoint as part of a POST request with a JSON payload. The event should be parsed and return a 2xx status code. Use type (<Model>.<action>) to determine what to do.

Example payload.

{
  "type": "Task.update",
  "event": {
    "id": 20004,
    "createdAt": 1673021684000,
    "task": {
      "id": 2,
      "status": {
        "id": 1,
        "name": "Todo",
        "isClosed": false
      }
    },
    "user": {
      "id": 1,
      "name": "Reon",
      "fullName": "Reon Walls",
      "avatarUrl": "/dummy/avatar1.png"
    },
    "project": {
      "id": 1,
      "name": "elephant-website",
      "fullName": "Elephant website development project"
    }
  },
  "url": {
    "ref": "https://<space>.repsona.com/p/1/status/2"
  }
}

Payload fields

FieldDescription
type<Model>.<action>. For example, Task.update
event.id / event.createdAtThe event ID and when it happened (UNIX time in milliseconds)
event.<model>The target. The key is the model name with a lowercase first letter (task, taskComment, etc.). Always includes id
event.userThe user who made the change
event.projectThe project of the target
url.refThe Repsona URL that opens the target

Event types

typeevent.<model>
Task.createtask: id, name, description, status, responsibleUser, ballHoldingUser, milestone, project, parent, priority, planned, actual, startDate, dueDate, tags
Task.updatetask: id and the changed fields. Adding or removing files sends id and files
TaskComment.create / TaskComment.updatetaskComment: id, comment, task, user
Note.createnote: id, name, description, isWip, project, parent
Note.updatenote: id and the changed fields (saving in the editor sends all the fields of Note.create). Adding or removing files sends id and files
NoteComment.create / NoteComment.updatenoteComment: id, comment, note, user
Reaction.createreaction: id, text, target, reactedUser, project

Fields that refer to other data are objects in the following shapes, not numeric IDs.

FieldShape
status{id, name, isClosed}
responsibleUser / ballHoldingUser / user / reactedUser{id, name, fullName, avatarUrl} (name is the username)
project{id, name, fullName}
milestone / parent / task / note{id, name}
files[{id, hash, filename, size, type}]
tags[{id, name}]
target{type, id}. type is one of project / taskComment / noteComment / user / activity / introduction

Configure the Webhook endpoint to Repsona.

From the Project Settings > Webhooks page, set the webhook endpoint URL and the event type to be notified The webhook endpoint URL must be a publicly accessible HTTPS URL.

Testing Webhook endpoints.

From the Project Settings > Webhooks page, test data can be sent to the registered URL. You can check the contents and results of the transmission in the transmission history list.

Send events including a signature in the Repsona-Signature header. This allows you to verify that the event was sent by Repsona and not by a third party. To verify the signature, the signature secret must have been previously obtained from the webhook configuration.

You can regenerate the signing secret in the webhook settings. The previous secret stops working immediately, so update your receiver with the new one.

The Repsona-Signature header in the event contains a timestamp and a signature. The timestamp is preceded by t= and the signature by s=.

Repsona-Signature: t=1674544389,s=768b05feb76b244902ab3a4eca119abb98e530ccbc3f2c48e18a7ed3a1cea0ab

Extracting timestamps and signatures from headers

To get a list of elements, split the header using the , character as a delimiter. Then, separate each element using the = character as a delimiter to get the prefix-value pairs. The value of the t prefix corresponds to the timestamp, while the s corresponds to the signature.

Preparing the signed_payload string

A signed_payload string is created by concatenating the following.

  • Timestamp (as a string)
  • Character .
  • The actual JSON payload (request body)

Determine the expected signature

Calculate the HMAC using the SHA256 hash function. Use the endpoint's signature secret as key and the signed_payload string as message.

Comparing signatures

Compares the signature in the header with the expected signature. If a match is found, the difference between the current timestamp and the received timestamp is calculated to determine if the difference is acceptable.

Repsona uses cookies to provide our services. By visiting our website, you agree to the use of cookies as described in our Cookie Policy.