Chúng tôi sẽ ngừng cung cấp API Tại chỗ. Hãy tham khảo tài liệu về việc Ngừng cung cấp API Tại chỗ để biết chi tiết, đồng thời tìm hiểu cách chuyển sang API Đám mây thế hệ tiếp theo của chúng tôi.

Messages garbage collector

/v1/services/message/gc

The /services/message/gc endpoint provides a way for businesses to delete messages from the database associated with their WhatsApp Business API client.

Before You Start

  • It is recommended you run this API request multiple times on larger databases (i.e., databases with a messages table containing more than 10 million rows) to ensure the callbacks returns a complete status and no errors.

Request

PUT /v1/services/message/gc

Response

HTTP responses

You should receive a response indicating the API request is being processed.

Single instance

{
    "services": {
        "message": {
            "gc": {
                "status": "processing"
            }
        }
    },
    "meta": {
        "api_status": "stable",
        "version": "3.0.0"
    }
}

Multiconnect

{
    "services": {
        "message": {
            "gc": {
                "wacore2:9dfe77618dba": {
                    "status": "processing"
                },
                "wacore3:a9dcc716fd6e": {
                    "status": "processing"
                }
            }
        }
    },
    "meta": {
        "version": "v2.29.1",
        "api_status": "stable"
    }
}

Webhook notifications

Since the API request works asynchronously, once the garbage collection on the messages table is complete, the WhatsApp Business API client will post a notification to the callback server in the following format.

Note:

  • For Multiconnect deployments, there will one notification posted per Coreapp.
  • The node field in the notification is optional and omitted for single instances.

Single instance

Account ID:  None
Request ID:  f1b61336390f46d8965888eaa6e8800b
10.254.254.254 - - [14/Jul/2020 13:01:15] "POST / HTTP/1.1" 200 -
{
    "services": [{
        "message": {
            "gc": {
                "messages_deleted": 5,
                "status": "complete"
            }
        }
    }]
}

Multiconnect

Account ID:  None
Request ID:  857d9be5438a4eb6ad795cf58ac7a3d2
10.254.254.254 - - [14/Jul/2020 10:26:34] "POST / HTTP/1.1" 200 -
{
    "services": [{
        "message": {
            "gc": {
                "messages_deleted": 11,
                "node": "wacore2:9dfe77618dba",
                "status": "complete"
            }
        }
    }]
}

Account ID:  None
Request ID:  857d9be5438a4eb6ad795cf58ac7a3d2
10.254.254.254 - - [14/Jul/2020 10:26:34] "POST / HTTP/1.1" 200 -
{
    "services": [{
        "message": {
            "gc": {
                "messages_deleted": 5,
                "node": "wacore3:a9dcc716fd6e",
                "status": "complete"
            }
        }
    }]
}

Errors

Errors Returned in Response

If the API request fails to initiate garbage collection, an error will be returned in the HTTP response.

Single instance

{
    "meta": {
        "version": "v2.29.1",
        "api_status": "stable"
    },
    "errors": [{
        "code": 1014,
        "title": "Internal error",
        "details": "Connection timed out. Please check if wacore is running: wacore:6252"
    }]
}

Multiconnect

{
    "services": {
        "message": {
            "gc": {
                "wacore1": {
                    "status": "processing"
                },
                "wacore2": {
                    "errors": [{
                        "code": 1014,
                        "title": "Internal error",
                        "details": "php_network_getaddresses: getaddrinfo failed: Name or service not known. Please check if wacore is running: wacore2:6252"
                    }]
                }
            }
        }
    },
    "meta": {
        "version": "v2.29.1",
        "api_status": "stable"
    }
}

Completion Failure

If the garbage collection fails to complete, an error will be returned in the Webhook notification.

Account ID:  None
Request ID:  192953cb41a547d0ab19bfde59bff010
10.254.254.254 - - [13/Jul/2020 10:07:51] "POST / HTTP/1.1" 200 -
{
    "services": [{
        "message": {
            "gc": {
                "messages_deleted": 0,
                "errors": [{
                    "code" : 1014,
                    "details" : "Failed to fetch processed messages to delete",
                }],
            "status": "failed"
            }
        }
    }]
}