Webhooks and callbacks are both mechanisms used to enable communication between different systems or components in software development, often for the purpose of executing code in response to specific events. However, they operate in different contexts and are used in different ways.

What are Callbacks?

Callbacks are functions that are passed as arguments to other functions or methods, and they are invoked (or “called back”) after the completion of a task or operation. Callbacks are a common pattern in programming, particularly in asynchronous operations, where you want to execute a piece of code after a certain task is done without blocking the main execution thread.

What are Webhooks?

Webhooks are a type of callback that operates over the web, allowing one system to send real-time data to another system as soon as an event occurs. Unlike traditional callbacks, which are typically defined within the same codebase or application, webhooks are used for communication between different applications or services over the internet.

PDF.co & Webhooks

Webhooks can be utilized by setting the callback object with the URL of your choice, which triggers a POST request to the specified webhook URL upon completion of the job process.

{
    "callback": "https://example.com/callback/url/you/provided"
}

The following APIs accept webhooks:

ControllerEndpoint
AI Invoice Parser Controllerai-invoice-parser
Barcode Controllerbarcode/generate, barcode/read/from/url
Convert to PDF Controllerxls/convert/to/pdf, pdf/convert/from/csv, pdf/convert/from/doc, pdf/convert/from/html, pdf/convert/from/image, pdf/convert/from/url, pdf/convert/from/email
Document Parser Controllerpdf/documentparser
Email Controlleremail/send, email/extract-attachments, email/decode
PDF Controllerpdf/merge, pdf/merge2, pdf/optimize, pdf/split, pdf/split2, pdf/info, pdf/info/fields, pdf/find, pdf/find/table, pdf/security/add, pdf/security/remove, pdf/classifier, pdf/attachments/extract
PDF Data Extraction Controllerpdf/convert/to/csv, pdf/convert/to/html, pdf/convert/to/json2, pdf/convert/to/text, pdf/convert/to/text-simple, pdf/convert/to/xls, pdf/convert/to/xlsx, pdf/convert/to/xml
PDF Edit Controllerpdf/makesearchable, pdf/makeunsearchable, pdf/edit/add, pdf/edit/rotate, pdf/edit/rotate/auto, pdf/edit/delete-pages, pdf/edit/replace-text, pdf/edit/delete-text, pdf/edit/replace-text-with-image
PDF to Image Controllerpdf/convert/to/jpg, pdf/convert/to/png, pdf/convert/to/webp, pdf/convert/to/tiff
XLS Controllerxls/convert/to/csv, xls/convert/to/html, xls/convert/to/json, xls/convert/to/txt, xls/convert/to/xml

Summary

Callbacks are functions passed into other functions to be executed after a task is completed, commonly used within the same codebase.

Webhooks are a type of callback that operates over the web, allowing one system to send data to another system when a specific event occurs, typically via an HTTP POST request.

In essence, webhooks are a practical implementation of the callback concept across different systems, facilitating real-time communication and integration between web applications.