---
updatedAt: 2025-09-16T12:12:31.000Z
agentTools:
  projectIndex: https://docs.testlify.com/llms.txt
---

# Create a new webhook

Create a webhook subscription to receive real-time notifications about assessment and candidate events.

# OpenAPI definition

```json
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Testlify API"
  },
  "tags": [
    {
      "name": "Webhook",
      "description": "Operations related to webhook management"
    }
  ],
  "servers": [
    {
      "url": "https://api.testlify.com/v1"
    }
  ],
  "paths": {
    "/webhook": {
      "post": {
        "tags": [
          "Webhook"
        ],
        "summary": "Create a new webhook",
        "description": "Create a webhook subscription to receive real-time notifications about assessment and candidate events.",
        "operationId": "create_webhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name",
                  "payloadUrl",
                  "events"
                ],
                "properties": {
                  "name": {
                    "type": "string",
                    "description": "Human-readable name for the webhook subscription",
                    "example": "Assessment Notifications"
                  },
                  "payloadUrl": {
                    "type": "string",
                    "format": "uri",
                    "description": "HTTPS endpoint URL where webhook events will be delivered",
                    "example": "https://example.com/webhooks/testlify"
                  },
                  "events": {
                    "type": "array",
                    "description": "Array of event types to subscribe to",
                    "items": {
                      "type": "string",
                      "enum": [
                        "created",
                        "updated",
                        "archived",
                        "deleted",
                        "completed",
                        "in_progress",
                        "candidateStatusChanged",
                        "invitation_expired",
                        "invited",
                        "enrolled",
                        "rejected",
                        "disqualified",
                        "score_updated",
                        "invited_for_interview",
                        "reinvited"
                      ]
                    },
                    "example": [
                      "created",
                      "completed",
                      "candidateStatusChanged"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created – webhook subscription created successfully",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "description": "Unique webhook identifier"
                    },
                    "orgId": {
                      "type": "string",
                      "description": "Organization identifier"
                    },
                    "userId": {
                      "type": "string",
                      "description": "User identifier who created the webhook"
                    },
                    "name": {
                      "type": "string",
                      "description": "Webhook subscription name"
                    },
                    "endpointId": {
                      "type": "string",
                      "description": "Internal endpoint identifier for webhook delivery"
                    },
                    "subscriptionId": {
                      "type": "string",
                      "description": "Internal subscription identifier"
                    },
                    "payloadUrl": {
                      "type": "string",
                      "format": "uri",
                      "description": "Endpoint URL for webhook delivery"
                    },
                    "events": {
                      "type": "array",
                      "description": "Subscribed event types",
                      "items": {
                        "type": "string"
                      }
                    },
                    "created": {
                      "type": "string",
                      "format": "date-time",
                      "description": "ISO-8601 timestamp when webhook was created"
                    },
                    "modified": {
                      "type": "string",
                      "format": "date-time",
                      "description": "ISO-8601 timestamp when webhook was last modified"
                    },
                    "restructureBySchema": {
                      "type": "boolean",
                      "description": "Flag indicating if payload should be restructured by schema"
                    },
                    "schemas": {
                      "type": "array",
                      "description": "Array of schema configurations for payload transformation",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "examples": {
                  "assessment_webhook": {
                    "summary": "Assessment lifecycle webhook",
                    "value": {
                      "id": "507f1f77bcf86cd799439011",
                      "orgId": "507f1f77bcf86cd799439022",
                      "userId": "507f1f77bcf86cd799439033",
                      "name": "Assessment Notifications",
                      "endpointId": "01HXMP8KQ7GBFN8RW2V4E9YZJX",
                      "subscriptionId": "01HXMP8L3M5HKFG9N2R6T8QWER",
                      "payloadUrl": "https://example.com/webhooks/testlify",
                      "events": [
                        "created",
                        "completed"
                      ],
                      "created": "2025-09-16T12:00:00.000Z",
                      "modified": "2025-09-16T12:00:00.000Z",
                      "restructureBySchema": false,
                      "schemas": []
                    }
                  },
                  "candidate_webhook": {
                    "summary": "Candidate status webhook",
                    "value": {
                      "id": "507f1f77bcf86cd799439044",
                      "orgId": "507f1f77bcf86cd799439055",
                      "userId": "507f1f77bcf86cd799439066",
                      "name": "Candidate Status Updates",
                      "endpointId": "01HXMP9RT5CDEF2KL8N4M7PQST",
                      "subscriptionId": "01HXMP9S2J6UVWX3N5Q8R9TYAB",
                      "payloadUrl": "https://hr-system.company.com/webhooks/candidates",
                      "events": [
                        "candidateStatusChanged",
                        "invited",
                        "completed",
                        "rejected"
                      ],
                      "created": "2025-09-16T12:15:00.000Z",
                      "modified": "2025-09-16T12:15:00.000Z",
                      "restructureBySchema": false,
                      "schemas": []
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request – validation or business logic errors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                },
                "examples": {
                  "invalid_event": {
                    "summary": "Invalid event type provided",
                    "value": {
                      "error": {
                        "statusCode": 400,
                        "name": "BadRequestError",
                        "message": "Invalid Event"
                      }
                    }
                  },
                  "organization_not_found": {
                    "summary": "Organization not found",
                    "value": {
                      "error": {
                        "statusCode": 400,
                        "name": "BadRequestError",
                        "message": "Organization Not Found"
                      }
                    }
                  },
                  "webhook_already_exists": {
                    "summary": "Webhook already exists for URL and event combination",
                    "value": {
                      "error": {
                        "statusCode": 400,
                        "name": "BadRequestError",
                        "message": "Webhook Found URL: https://example.com/webhook & Event: created"
                      }
                    }
                  },
                  "convoy_endpoint_error": {
                    "summary": "Error adding webhook endpoint to convoy service",
                    "value": {
                      "error": {
                        "statusCode": 400,
                        "name": "BadRequestError",
                        "message": "Error in adding webhook to convoy"
                      }
                    }
                  },
                  "convoy_subscription_error": {
                    "summary": "Error adding webhook subscription to convoy service",
                    "value": {
                      "error": {
                        "statusCode": 400,
                        "name": "BadRequestError",
                        "message": "Error in adding webhook subscription to convoy"
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "name": {
                          "type": "string"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "examples": {
                  "jwt_malformed": {
                    "summary": "JWT malformed error",
                    "value": {
                      "error": {
                        "statusCode": 401,
                        "name": "UnauthorizedError",
                        "message": "Error verifying token : jwt malformed"
                      }
                    }
                  },
                  "token_expired": {
                    "summary": "Access token expired",
                    "value": {
                      "error": {
                        "statusCode": 401,
                        "name": "UnauthorizedError",
                        "message": "Access token expired"
                      }
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "Not Found – URL or resource not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EntityNotFoundError"
                },
                "examples": {
                  "url_not_found": {
                    "summary": "Webhook endpoint URL not reachable",
                    "value": {
                      "error": {
                        "statusCode": 404,
                        "name": "EntityNotFoundError",
                        "message": "URL Not Found",
                        "code": "WEBHOOK_URL_NOT_REACHABLE"
                      }
                    }
                  }
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity – validation failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableEntityError"
                },
                "example": {
                  "error": {
                    "statusCode": 422,
                    "name": "UnprocessableEntityError",
                    "message": "The request body is invalid. See error object `details` property for more info.",
                    "code": "VALIDATION_FAILED",
                    "details": [
                      {
                        "path": "",
                        "code": "required",
                        "message": "must have required property 'events'",
                        "info": {
                          "missingProperty": "events"
                        }
                      }
                    ]
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal Server Error",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "error": {
                      "type": "object",
                      "properties": {
                        "statusCode": {
                          "type": "number"
                        },
                        "message": {
                          "type": "string"
                        }
                      }
                    }
                  }
                },
                "example": {
                  "error": {
                    "statusCode": 500,
                    "message": "Internal Server Error"
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "BearerAuth": []
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "schemas": {
      "BadRequestError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "statusCode": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "UnprocessableEntityError": {
        "type": "object",
        "properties": {
          "error": {
            "$ref": "#/components/schemas/UnprocessableEntityErrorDetail"
          }
        }
      },
      "UnprocessableEntityErrorDetail": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "integer"
          },
          "name": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "details": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "path": {
                  "type": "string"
                },
                "code": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                },
                "info": {
                  "type": "object"
                }
              }
            }
          }
        }
      },
      "EntityNotFoundError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "statusCode": {
                "type": "integer"
              },
              "name": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "code": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
```