Create a webhook
POST
/webhooks
const url = 'https://docs.ywork.dev/api/v1/webhooks';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"url":"https://example.com/hooks/ywork","events":["task.created","task.updated"]}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://docs.ywork.dev/api/v1/webhooks \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "url": "https://example.com/hooks/ywork", "events": [ "task.created", "task.updated" ] }'Authorizations
Section titled “Authorizations”Request Bodyrequired
Section titled “Request Bodyrequired”Media typeapplication/json
object
url
required
string format: uri
events
required
Array<string>
Example
{ "url": "https://example.com/hooks/ywork", "events": [ "task.created", "task.updated" ]}Responses
Section titled “Responses”The created webhook.
Media typeapplication/json
object
id
required
string
object
required
string
url
required
string format: uri
events
required
Array<string>
created_at
required
string format: date-time
Example
{ "id": "whk_1Za7Yb3cVn", "object": "webhook", "url": "https://example.com/hooks/ywork", "events": [ "task.created" ]}No valid API key was provided.
Media typeapplication/json
object
error
required
object
type
required
A broad category for the error.
string
code
required
A short machine-readable code for the specific error.
string
message
required
A human-readable description of the error.
string
request_id
A unique identifier for the request, useful for support.
string
Example
{ "error": { "type": "authentication_error", "code": "missing_api_key", "message": "No API key provided. Send your key as a bearer token in the Authorization header.", "request_id": "req_9f2a1c7b4e" }}The request body failed validation.
Media typeapplication/json
object
error
required
object
type
required
A broad category for the error.
string
code
required
A short machine-readable code for the specific error.
string
message
required
A human-readable description of the error.
string
request_id
A unique identifier for the request, useful for support.
string
Example
{ "error": { "type": "invalid_request_error", "code": "validation_failed", "message": "The 'name' field is required.", "request_id": "req_7c3f5a9e12" }}