# Read workflow results

After a form starts a [DataAgents workflow](/data-agents/workflows/), check the job status to see whether the run finished. To receive an enriched lead or CRM record ID, configure a workflow action to send those fields to your application.

## Check a run

Set `JOB_ID` to the `id` from the trigger response and `SNAPADDY_API_KEY` to your [personal API token](/authentication/). These examples read one status update.

```bash
curl --fail-with-body "https://backend.snapaddy.com/job-management/jobs/$JOB_ID" \
  -H "x-api-key: $SNAPADDY_API_KEY" | jq '{state, failedReason}'
```

```typescript
const url = `https://backend.snapaddy.com/job-management/jobs/${process.env.JOB_ID}`;
const response = await fetch(url, { headers: { "x-api-key": process.env.SNAPADDY_API_KEY! } });
if (!response.ok) throw new Error(`Job lookup failed (${response.status})`);
const { state, failedReason } = await response.json();
console.log(state, failedReason);
```

```python
import json, os
from urllib.request import Request, urlopen

url = f"https://backend.snapaddy.com/job-management/jobs/{os.environ['JOB_ID']}"
request = Request(url, headers={"x-api-key": os.environ["SNAPADDY_API_KEY"]})
with urlopen(request, timeout=20) as response:
    job = json.load(response)
print(job["state"], job.get("failedReason"))
```

While the state is `waiting` or `active`, wait before checking again. Workflow progress stays at zero because the number of steps can vary. Stop polling at `completed`, `failed`, or `canceled`. On failure, read `failedReason` and inspect the log. The workflow job’s `returnValue` has no business output fields. The original trigger payload is available under `data.data`.

## Inspect the execution log

For example, if the lead never appeared in your CRM, inspect the entries for its run. The Workflow service returns entries in creation order. You need DataAgents access in the organization that owns the job.

```bash
curl --fail-with-body --get 'https://backend.snapaddy.com/workflow/v1/logs' \
  -H "x-api-key: $SNAPADDY_API_KEY" --data-urlencode "jobId=$JOB_ID" \
  --data-urlencode 'limit=50' --data-urlencode 'offset=0' |
  jq '.[] | {createdAt, type, nodeId, nodeType}'
```

```typescript
const url = new URL("https://backend.snapaddy.com/workflow/v1/logs");
url.search = new URLSearchParams({ jobId: process.env.JOB_ID!, limit: "50", offset: "0" }).toString();
const response = await fetch(url, { headers: { "x-api-key": process.env.SNAPADDY_API_KEY! } });
if (!response.ok) throw new Error(`Log lookup failed (${response.status})`);
for (const entry of await response.json()) console.log(entry.createdAt, entry.type, entry.nodeId, entry.nodeType);
```

```python
import json, os
from urllib.parse import urlencode
from urllib.request import Request, urlopen

query = urlencode({"jobId": os.environ["JOB_ID"], "limit": 50, "offset": 0})
url = f"https://backend.snapaddy.com/workflow/v1/logs?{query}"
request = Request(url, headers={"x-api-key": os.environ["SNAPADDY_API_KEY"]})
with urlopen(request, timeout=20) as response:
    for entry in json.load(response):
        print(entry["createdAt"], entry["type"], entry.get("nodeId"), entry.get("nodeType"))
```

An entry’s `payload` contains details specific to its type. A run-level entry can have a null `nodeId`. Increase `offset` by the number of entries received and stop when a page is shorter than the requested limit. Each page can contain up to 100 entries. [Workflow logs reference](/reference/workflow-logs/)

## Deliver the processed lead

Include your own submission ID in the trigger data, for example `"submissionId": "lead-1042"`. In the workflow editor, add an HTTP request action after the step that enriches the lead or writes to the CRM. Choose `POST`, enter your server’s HTTPS receiver URL, and map the submission ID and the fields your application needs into the JSON body. Configure authentication for your receiver in the action.

For example, your receiver could accept `{"submissionId":"lead-1042","crmId":"contact-238"}`. Store the CRM ID against that submission and handle repeat deliveries for the same submission. The field names in this example belong to your application. [Workflow node documentation](https://workflow-docs.snapaddy.com/)
