Skip to main content
You can embed Dmand AI’s NPI-to-email enrichment directly in your product so your users get verified provider emails without leaving your app. This guide covers the integration pattern: submit asynchronously, receive results by webhook, and map them back to your records with custom_data.

1. Submit asynchronously

When a user requests enrichment, submit the NPI (or up to 100 NPIs). The API responds with HTTP 202 immediately.

2. Store batch and request IDs

Both single and bulk submits return a batch_id and a requests array. Persist these so you can poll or reconcile later:

3. Handle webhooks

With mode: "real-time", your endpoint receives one POST per NPI as it resolves, so you can update your UI progressively. With mode: "batch", you receive one webhook when the entire batch completes. Your handler should:
  1. Parse the JSON payload.
  2. Read custom_data to find the tenant and user.
  3. For each item in data, update the record by npi using its status and email fields.
  4. Return a 2xx status quickly.
app.py
Make your handler idempotent: deduplicate by request_id. If your endpoint returns a non-2xx response, Dmand retries delivery with backoff. See Webhooks for the payload format.

4. Match results with custom_data

custom_data accepts any JSON object and comes back unchanged in every webhook and poll response. Use it for your tenant, user, or record IDs instead of matching on names.

5. Use Idempotency-Key for safe retries

If a submit request fails on the network, retry with the same Idempotency-Key header value so the retry does not create a duplicate submission. Use a UUID or a hash of the request body.

6. Check credits before large jobs

Before you enqueue a large number of NPIs, verify you have enough credits:
Credits are held at submit, charged only for emails found, and refunded for not_found or failed NPIs. Re-requesting the same NPI within 30 days is free (replayed: true), so you don’t need to deduplicate recent lookups yourself. See GET /credits and Credits.

7. Keep polling as a fallback

If a webhook does not arrive, poll GET /api/v1/batch/{batch_id} or the poll_url of each request until no item is accepted or in-progress.

Next steps