[{"data":1,"prerenderedAt":20},["ShallowReactive",2],{"blog-post-en-send-phoma-flow-results-to-external-apis":3},{"slug":4,"lang":5,"title":6,"summary":7,"date":8,"tags":9,"tag_slugs":15,"thumbnail_url":16,"translations":17,"body":18,"asset_base":19},"send-phoma-flow-results-to-external-apis","en","Send Phoma Flow Results to External APIs Using the HTTP Request Step","Learn how to configure Phoma's HTTP Request step to POST flow outcomes, screenshots, and custom data to any REST endpoint, enabling seamless CI/CD integration and real‑time reporting.","2026-11-12",[10,11,12,13,14],"http","integration","reporting","cicd","automation",[10,11,12,13,14],"https://blog-api.phomaapp.com/api/blog/posts/send-phoma-flow-results-to-external-apis/thumbnail.svg?lang=en",[5],"## Why push flow results out of Phoma?\n\nPhoma runs flows locally on your Windows machine and the Android devices you own. That keeps data private and costs predictable, but it also means the results — pass/fail status, extracted text, screenshots, timing — stay inside the app unless you export them. Sending those results to an external system unlocks several practical workflows:\n\n* **Centralised test dashboards** – push every run into a test‑management tool (TestRail, Zephyr, a custom DB) so the whole team sees a single source of truth.\n* **CI/CD gates** – a failing flow can POST a payload that triggers a pipeline step, blocks a merge, or opens a ticket.\n* **Audit trails** – store raw screenshots and element‑tree snapshots in object storage for later regression analysis.\n* **Real‑time alerts** – forward critical failures to Slack, Teams, or PagerDuty via a webhook.\n\nAll of this is possible with Phoma’s **HTTP Request** step, which lets you call any REST endpoint from inside a visual flow — no code, no external scripts.\n\n## Prerequisites\n\nBefore you start, make sure you have:\n\n1. **Phoma installed** on Windows (free tier is enough).\n2. **At least one Android device** connected via USB or Wi‑Fi ADB and visible in Phoma.\n3. **A flow** that already performs the actions you want to measure (login, data entry, smoke test, etc.).\n4. **An HTTP endpoint** that accepts `POST` (or `PUT`/`PATCH`) with a JSON body. It can be a public webhook, an internal API, or a serverless function.\n5. **Network reachability** from the Windows host to the endpoint (firewall, VPN, proxy).\n\n## Understanding the HTTP Request step\n\nThe HTTP Request step is a first‑class flow action, just like *Tap*, *Swipe*, or *Wait for Element*. When the flow reaches it, Phoma builds the request on the Windows host, sends it, and optionally stores the response for later steps (conditions, logging, branching).\n\nKey configurable fields:\n\n| Field | Purpose | Typical value |\n|-------|---------|---------------|\n| **Method** | HTTP verb | `POST` (most common) |\n| **URL** | Full endpoint, can contain variables | `https://api.example.com/phoma/results` |\n| **Headers** | Key‑value pairs, e.g. authentication, content‑type | `Authorization: Bearer {{secrets.api_token}}` |\n| **Body** | JSON payload; you can embed any flow variable | See example below |\n| **Timeout (ms)** | Max time to wait for a response | `10000` |\n| **Store response as** | Variable name for the response body / status | `http_response` |\n\n> **Tip:** Phoma evaluates variables (double‑curly syntax) **just before** sending the request, so you can include dynamic data such as the device serial, current timestamp, or a base‑64 screenshot.\n\n## Step‑by‑step: Add an HTTP Request step to a flow\n\n1. **Open the flow** in Phoma’s visual builder.\n2. **Drag an *HTTP Request* step** from the palette onto the canvas, placing it after the last functional step (e.g., after a *Text Assertion* or *Screenshot*).\n3. **Configure the basics**:\n   - **Method** → `POST`\n   - **URL** → your endpoint (e.g., `https://hooks.slack.com/services/XXX/YYY/ZZZ` for a Slack webhook).\n   - **Headers** → add `Content-Type: application/json` and any auth header.\n4. **Build the JSON payload** in the *Body* editor. Use the variable picker (the `{{ }}` button) to insert flow‑level variables.\n5. **Set *Store response as*** to a name like `post_result` so you can inspect status codes later.\n6. **Add a *Condition* step** (optional) right after the HTTP Request to branch on `post_result.status == 200`.\n7. **Save and run** the flow on a single device to verify the request succeeds.\n\n### Example payload\n\n```json\n{\n  \"flow_name\": \"{{flow.name}}\",\n  \"device_serial\": \"{{device.serial}}\",\n  \"run_id\": \"{{run.id}}\",\n  \"timestamp_utc\": \"{{run.started_at_utc}}\",\n  \"status\": \"{{flow.status}}\",\n  \"duration_ms\": \"{{flow.duration_ms}}\",\n  \"assertions\": [\n    {\"name\": \"login_success\", \"passed\": {{step.login_assertion.passed}}},\n    {\"name\": \"dashboard_loaded\", \"passed\": {{step.dashboard_assertion.passed}}}\n  ],\n  \"screenshot_base64\": \"{{step.final_screenshot.base64}}\",\n  \"custom\": {\n    \"build_number\": \"{{env.BUILD_NUMBER}}\",\n    \"git_sha\": \"{{env.GIT_COMMIT}}\"\n  }\n}\n```\n\n*All `{{…}}` placeholders are replaced at runtime.* Phoma exposes a rich set of built‑in variables (flow metadata, device info, step results, screenshots) and you can also inject environment variables from the Windows host (`{{env.VAR_NAME}}`).\n\n### Using variables effectively\n\n| Variable | Description | Example use |\n|----------|-------------|-------------|\n| `{{flow.name}}` | Name of the current flow | Identify which test suite ran |\n| `{{device.serial}}` | ADB serial of the phone | Correlate results per device |\n| `{{run.id}}` | Unique run UUID | Deduplicate in the backend |\n| `{{step.\u003Cstep_id>.passed}}` | Boolean result of a preceding assertion | Build a pass/fail matrix |\n| `{{step.\u003Cstep_id>.text}}` | Text read by a *Read Text* step | Send scraped data |\n| `{{step.\u003Cstep_id>.screenshot.base64}}` | Base64‑encoded PNG of a *Screenshot* step | Attach visual proof |\n| `{{env.VAR}}` | Any Windows environment variable | Inject CI build numbers |\n\n## Authenticating with the API\n\nMost production endpoints require authentication. Phoma does not store secrets, so you have two practical options:\n\n1. **Environment variables on the Windows host** – set `PHOMA_API_TOKEN` in the system or user environment, then reference it as `{{env.PHOMA_API_TOKEN}}` in the *Authorization* header.\n2. **Phoma’s built‑in *Secrets* panel** (Team/Business plans) – define a secret named `api_token` and use `{{secrets.api_token}}`. This keeps the token out of the flow file and allows rotation without editing flows.\n\nExample header row:\n\n```\nAuthorization: Bearer {{secrets.api_token}}\nContent-Type: application/json\n```\n\nIf your endpoint uses **Basic Auth**, encode `username:password` in base64 on the host and store the resulting string as a secret.\n\n## Handling success and failure\n\nAfter the HTTP Request step, add a *Condition* step to act on the response:\n\n```\n{{post_result.status}} == 200\n```\n\n* **True branch** – continue normal flow, maybe log a success screenshot.\n* **False branch** – trigger a *Notification* step (email, Slack webhook) or *Fail Flow* step to mark the run as failed in Phoma’s UI.\n\nYou can also inspect `{{post_result.body}}` for error details returned by the API.\n\n## Scheduling and running on multiple devices\n\nPhoma’s **Multi‑Device Run** launches the same flow on every selected phone **in parallel** (or sequentially, if you prefer). Each device executes its own HTTP Request step, sending a payload that includes its unique `{{device.serial}}`. This means your backend receives one request per device per run — ideal for aggregating per‑device pass rates.\n\nTo schedule:\n\n1. Open the **Scheduler** tab.\n2. Create a new schedule, pick the flow, choose *All devices* or a device group.\n3. Set cron expression (e.g., `0 2 * * *` for 02:00 daily).\n4. Enable *Run only if devices are online* to avoid stale runs.\n\nThe scheduler runs on the Windows host, so the machine must be awake and the Phoma service running.\n\n## Troubleshooting common issues\n\n| Symptom | Likely cause | Fix |\n|---------|--------------|-----|\n| **Request times out** | Firewall / proxy blocks outbound traffic | Allow Phoma (`Phoma.exe`) through Windows Firewall; configure proxy in Phoma *Settings → Network*. |\n| **401 Unauthorized** | Token expired or wrong header format | Verify secret value; ensure `Bearer ` prefix; check token scopes. |\n| **Payload too large** | Base64 screenshot exceeds API limit | Resize screenshot step (*Set screenshot quality* to 50 %); or upload screenshot to object storage first and send only the URL. |\n| **SSL certificate error** | Self‑signed cert on internal API | Add the CA to Windows Trusted Root Certification Authorities, or disable cert validation in Phoma *Settings → Advanced* (not recommended for production). |\n| **Variables not resolving** | Typo in variable name or step not executed yet | Use the *Variable Picker* UI; ensure the referenced step runs before the HTTP Request. |\n\n## Best practices\n\n1. **Keep payloads lean** – send only what the consumer needs. Large base64 images bloat logs and increase latency.\n2. **Version your payload schema** – add a `schema_version` field so downstream consumers can evolve without breaking.\n3. **Idempotency** – include `{{run.id}}` so the backend can deduplicate retries.\n4. **Secure secrets** – never hard‑code tokens in the flow; always use `{{secrets.*}}` or `{{env.*}}`.\n5. **Test locally first** – run the flow on a single device with a request bin (e.g., `https://webhook.site`) to inspect the exact JSON sent.\n6. **Monitor API health** – add a simple *HTTP Request* health‑check flow that runs every 5 minutes; alert on non‑2xx.\n\n## Next steps\n\n* **Integrate with CI/CD** – use the same HTTP Request step to post results to GitHub Actions, GitLab CI, or Azure DevOps via their APIs.\n* **Build a dashboard** – feed the JSON into Elasticsearch, Grafana, or a custom React app for real‑time visibility.\n* **Explore conditional branching** – combine the HTTP response with *Condition* and *Loop* steps to retry flaky actions before reporting failure.\n* **Read the “Choose Stable Android Element Selectors for Phoma Flows” guide** to make the upstream steps more reliable, so the data you send is trustworthy.\n\nBy wiring Phoma’s HTTP Request step into your existing tooling, you turn every automated run into a first‑class data point — no extra scripts, no cloud device farms, just the phones and the Windows machine you already own.\n","https://blog-api.phomaapp.com/api/blog/posts/send-phoma-flow-results-to-external-apis/assets",1796035641445]