| copyright |
|
||
|---|---|---|---|
| lastupdated | 2025-02-13 | ||
| keywords | external-enrichment,webhook | ||
| subcollection | discovery-data |
{{site.data.keyword.attribute-definition-list}}
{: #document-status-api}
You can use the document status webhook feature to send a webhook event to your external application when the status of ingested documents becomes available or failed. The webhook event helps you to take the next action on indexed documents, without having to get the document status first through the Get document details API{: external}.
[IBM Cloud Pak for Data]{: tag-cp4d} [IBM Software Hub]{: tag-teal} When you run {{site.data.keyword.discoveryshort}} in an air-gapped environment, you must connect to the external application through an HTTP proxy. For more information, see Setting up HTTP proxy in air-gapped environments. {: note}
For using the document status webhook feature, do the following things:
-
Set up the external application that can receive webhook notifications from {{site.data.keyword.discoveryshort}}.
To do so, you must register your external application as a webhook endpoint on a collection by using the
create collectionorupdate collectionAPI methods. For more information, see Create collection{: external} or update collection{: external} in the API reference.The external application receives a webhook
pingevent, which notifies that the webhook is sucessfully created. The external application must be accessible from IBM Cloud. -
Ingest the documents to the collection. When the status of the ingested documents becomes
availableorfailed, the external application receives thedocument.statuswebhook event.You can verify the status of the ingested documents in the
dataobject of thedocument.statuswebhook event. Thedocument_idsandstatusparameters show the IDs of the ingested documents and their status. For more information, see Data model of thepingevent and Data model of thedocument.statusevent.
The following image shows the webhook configuration flow.
{: caption="Document status webhook feature configuration flow" caption-side="bottom"}
The following image shows the document status webhook feature process flow.
{: caption="Document status webhook feature process flow" caption-side="bottom"}
For more information about the query API, see Query a project API method{: external} in the API reference.
You can also refer to the webhook-doc-status-sample application for the document status webhook API feature. To view the sample application, you must have access to the Discovery doc-tutorial-downloads{: external} repository.
{{site.data.content.webhook-security-reuse}}
{{site.data.content.ping-event-reuse}}
For example, following is a ping event that is sent to a webhook:
POST https://example.com/webhook
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
X-Global-Transaction-ID: 5144bb45-dc81-402c-a045-249fd1318515
Content-Type: application/json
{
"event": "ping",
"version": "2023-03-31",
"instance_id": "1a5d4916-6097-4150-977a-ca897226565c",
"data": {
"url": "https://example.com/webhook",
"events": [
"document.status"
],
"metadata": {
"project_id": "02a803f9-c814-4fcb-a764-e01e3d4dd002",
"collection_id": "f41ae858-0ca9-d0ed-0000-01890118cc5b"
}
},
"created_at": "2023-08-16T08:34:46.000Z"
}{: codeblock}
{: #document.status-event}
Following are the document.status event parameters:
| Parameter | Description |
|---|---|
event |
The event name is document.status. |
instance_id |
The {{site.data.keyword.discoveryshort}} instance ID. |
version |
The {{site.data.keyword.discoveryshort}} API version in the format yyyy-mm-dd. |
data |
An object with the event specific information: project_id, collection_id, and document_ids. |
status |
The status of the documents. |
created_at |
The date and time the event was created. |
| {: caption=" Document.status event" caption-side="top"} |
For example, following is a document.status event that is sent to a webhook:
POST https://example.com/webhook
Authorization: Basic YWxhZGRpbjpvcGVuc2VzYW1l
X-Global-Transaction-ID: 5144bb45-dc81-402c-a045-249fd1318515
Content-Type: application/json
{
"event": "document.status",
"version": "2023-03-31",
"instance_id": "1a5d4916-6097-4150-977a-ca897226565c",
"data": {
"project_id": "02a803f9-c814-4fcb-a764-e01e3d4dd002",
"collection_id": "f41ae858-0ca9-d0ed-0000-01890118cc5b",
"document_ids": [
"1a5d4916-6097-4150-977a-ca897226565b",
"2a5d4916-6097-4150-977a-ca897226565b"
],
"status": "available"
},
"created_at": "2023-08-16T08:34:46.000Z"
}{: codeblock}