When to Use
- Health monitoring dashboards: On a schedule, check whether the last run of a critical scraping actor succeeded. Alert via Slack or email if the most recent run has status
FAILED or TIMED-OUT.
- Incremental data pipelines: Retrieve the
defaultDatasetId from the most recent successful run of an actor without knowing the run ID in advance — useful when actors are triggered externally (e.g. via Apify scheduler) and results need to be pulled into BizFirstAI for processing.
- Cost reporting: Summarize
usageTotalUsd from the last run of multiple actors to produce a daily usage report without storing run IDs.
- Resuming from last known state: When a workflow is re-triggered after a gap, use
actor/getLastRun with status: "SUCCEEDED" to find the most recent good dataset before deciding whether to re-run or reuse existing results.
- Post-run data retrieval: When actor runs are triggered externally (via cron or API) and BizFirstAI only needs to consume the output,
getLastRun provides a stable entry point without coupling the trigger and consumer workflows.
Status filter: The status config key (mapped to StatusFilter) accepts any valid Apify run status: READY, RUNNING, SUCCEEDED, FAILED, TIMED-OUT, ABORTING, ABORTED. If omitted, the most recent run regardless of status is returned. Use SUCCEEDED to skip over runs that are still in progress.
Configuration
Connection
| Field | Required | Description |
credentialId | Required | BizFirstAI credential ID holding the Apify API token. |
baseUrl | Optional | Apify API base URL. Defaults to https://api.apify.com. |
Operation
| Field (config key) | Required | Description |
resource | Required | Must be "actor". |
operation | Required | Must be "get-last-run". |
actorId | Required | The actor to query. Accepts username~actor-name format or a raw actor ID string. |
status | Optional | Filter to return only the last run with this status. Accepted values: READY, RUNNING, SUCCEEDED, FAILED, TIMED-OUT, ABORTING, ABORTED. If omitted, the absolute last run is returned regardless of status. |
Sample Configuration
{
"resource": "actor",
"operation": "get-last-run",
"credentialId": "apify-prod-token",
"actorId": "apify~web-scraper",
"status": "SUCCEEDED"
}
Validation Errors
| Error | Cause |
API token is required | credentialId / apiToken is missing or empty. |
Actor ID is required | actorId is missing or empty. |
Invalid settings for actor/get-last-run | Internal settings type mismatch. Verify resource is "actor" and operation is "get-last-run". |
APIFY_ERROR (error port) | Apify API returned an error — no runs exist for this actor, invalid actor ID, or insufficient permissions. |
Output
Success Port
| Field | Type | Description |
runId | string | Unique identifier for the returned run. |
actorId | string | The actor that produced this run. |
runStatus | string | Final or current status of the run. |
startedAt | string | ISO 8601 timestamp when the run started. |
finishedAt | string | ISO 8601 timestamp when the run finished. Empty string if still in progress. |
defaultDatasetId | string | Dataset ID for this run's output. Pass to dataset/getItems. |
defaultKeyValueStoreId | string | Key-value store ID for this run. |
defaultRequestQueueId | string | Request queue ID for this run. |
usageTotalUsd | number | Total compute cost for this run in USD. |
exitCode | number | Actor exit code. 0 = success, -1 if not finished. |
Error Port
Routes here when no run exists for the actor (or no run matches the status filter), when the actor ID is invalid, or when the API returns any non-success status. Output contains errorCode ("APIFY_ERROR"), message, and operation ("get-last-run").
No matching run: If no run exists for the actor that matches the given status filter, Apify returns a 404 and the node routes to the error port. Always handle the error port in monitoring workflows to distinguish "no successful run yet" from a genuine API error.
Sample Output
{
"runId": "run_7g8h9i0j1k2l",
"actorId": "moJRLRc85AitArpNN",
"runStatus": "SUCCEEDED",
"startedAt": "2026-05-26T06:00:01.000Z",
"finishedAt": "2026-05-26T06:04:37.000Z",
"defaultDatasetId": "ds_m3n4o5p6q7r8",
"defaultKeyValueStoreId": "kvs_s9t0u1v2w3x4",
"defaultRequestQueueId": "rq_y5z6a7b8c9d0",
"usageTotalUsd": 0.0284,
"exitCode": 0
}
Expression Reference
| Expression | Returns |
{{ $output.apify.runId }} | Run ID of the most recent matching run. |
{{ $output.apify.runStatus }} | Status of the run (e.g. "SUCCEEDED"). |
{{ $output.apify.defaultDatasetId }} | Dataset ID to pass to dataset/getItems. |
{{ $output.apify.finishedAt }} | Completion timestamp for audit or display. |
{{ $output.apify.usageTotalUsd }} | Cost of the run in USD for billing summaries. |
{{ $output.apify.exitCode }} | Exit code — use in an IfCondition to branch on success vs failure. |
Node Policies & GuardRails
| Policy | Recommendation | Severity |
| API token storage | Use credentialId; never embed raw tokens in configuration. | Critical |
| Error port on no-run | Always connect and handle the error port. A 404 from Apify (no matching run) routes here — treat it as a distinct case from a scraping failure. | High |
| Status filter precision | Use status: "SUCCEEDED" in production monitoring to avoid accidentally picking up a currently-running or failed run and treating its dataset as complete output. | High |
| Stale data risk | The last run may be days or weeks old. Add a timestamp check using finishedAt in a downstream IfCondition node to reject runs older than your acceptable data freshness window. | Medium |
| Rate limiting | Avoid calling getLastRun in tight polling loops (under 5-second intervals). Use actor-run/get with a known run ID for active-run polling instead. | Medium |
Examples
Scheduled Health Check — Alert on Last Run Failure
{
"resource": "actor",
"operation": "get-last-run",
"credentialId": "apify-prod-token",
"actorId": "my-org~product-price-monitor"
}
Run every 15 minutes via a scheduled trigger. An IfCondition downstream checks {{ $output.apify.runStatus }} !== "SUCCEEDED". If true, a Slack node posts an alert to the ops channel with the runId and runStatus.
Consume Last Successful Scrape Results
{
"resource": "actor",
"operation": "get-last-run",
"credentialId": "apify-prod-token",
"actorId": "apify~google-search-scraper",
"status": "SUCCEEDED"
}
Retrieves the most recent successful run. The defaultDatasetId is then passed to a dataset/getItems node to load the search results into the workflow for further processing — without needing to store the run ID externally.
Daily Cost Report Across Multiple Actors
{
"resource": "actor",
"operation": "get-last-run",
"credentialId": "apify-billing-token",
"actorId": "{{ $output.actorLoop.currentActorId }}",
"status": "SUCCEEDED"
}
Inside a Loop node iterating over an array of actor IDs, this node fetches the last successful run for each and accumulates usageTotalUsd values. The loop output is passed to a reporting node that generates a daily cost summary email.