Skip to main content

Asynchronous Processing Overview

Asynchronous processing allows you to upload food images and receive immediate responses while the AI analysis happens in the background. This approach provides better user experience for interactive applications and enables you to handle multiple requests efficiently.

How Asynchronous Processing Works

  1. Upload Image — send a POST request with wait_on_process: false (default)
  2. Immediate Response — receive a response with status: "pending" or status: "processing", and a record_id
  3. Background Processing — AI models analyze the image (typically 4–30 seconds)
  4. Get Results — receive webhook notification with an analysis report when finished

Getting Results

Webhooks

Configure a webhook URL to receive real-time notifications when analysis completes: Request:
Immediate Response:
Webhook Notification (when analysis completes):

Alternative: Manual Checking

If webhooks are not available in your environment, you can check the status using the GET /nutrition_records/{id} endpoint:

Webhook Configuration

Setup

Configure your webhook URL through the admin console. Your endpoint must:
  • Respond with HTTP 200 to acknowledge receipt
  • Handle POST requests with JSON payloads
  • Verify HMAC signatures for security
If requests fail, the system retries up to 10 times with exponential backoff.

Security

All webhook requests include HMAC SHA256 signature verification:
  • Headerx-body-signature contains the hex-encoded HMAC signature
  • Key — uses your application’s webhook signature key (configured in the admin console)
  • AlgorithmHMAC-SHA256(webhook_signature_key, request_body)
See Webhook Signature for more details.

Status Handling

Your webhook handler should handle different status values. For complete status definitions, see Processing Status. When status is failed, check the failure_reason field for specific details about what prevented successful analysis.

Best Practices

1. Webhook Implementation

  • Respond quickly — always respond with HTTP 200 immediately, then process data asynchronously
  • Validate signatures — always verify the HMAC signature before processing webhook data
  • Handle failures gracefully — check the status field and handle both success and failure cases
  • Implement idempotency — use the record_id to avoid processing the same webhook multiple times

2. Error Handling

  • Handle webhook delivery failures gracefully
  • Store webhook secrets securely and never commit them to version control
  • Implement retry logic for critical webhook processing

3. User Experience

  • Show immediate feedback when the image is uploaded (“Analysis in progress…”)
  • Provide loading indicators during the processing window
  • Handle both success and failure states in your UI

Use Cases

Asynchronous processing is ideal for:
  • Mobile applications — immediate feedback while processing happens in the background
  • Web applications — non-blocking user interfaces with real-time updates
  • High-volume scenarios — process multiple images concurrently
  • User-facing tools — food logging apps, dietary tracking applications

Implementation Examples

For complete API specifications and additional configuration options, see the Implementation Guide.