> ## Documentation Index
> Fetch the complete documentation index at: https://docs.stackone.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Data Sync

> Cache provider data so reads don't hit the source every time.

Data Sync writes an action's result to a StackOne-managed index, then serves reads from that index instead of calling the provider. Use it for data an agent reads often — fast, repeatable reads without re-fetching from the source each time.

## How it works

<Steps>
  <Step title="Write a run to the index">
    Add `?sync=true` to a normal RPC call. StackOne runs the action against the provider and stores the result.

    ```bash theme={null}
    curl -X POST "https://api.stackone.com/actions/rpc?sync=true" \
      -u "$STACKONE_API_KEY:" \
      -H "x-account-id: customer-bamboohr" \
      -H "Content-Type: application/json" \
      -d '{ "action": "bamboohr_list_employees", "query": { "page_size": 25 } }'
    ```

    The response includes a `datasync` block with `synced_at`, `sync_expires_at`, and a `params_hash`.
  </Step>

  <Step title="Read synced data back">
    Call `/actions/rpc/synced` with the same action and params. StackOne returns the stored records without touching the provider.

    ```bash theme={null}
    curl -X POST "https://api.stackone.com/actions/rpc/synced" \
      -u "$STACKONE_API_KEY:" \
      -H "x-account-id: customer-bamboohr" \
      -H "Content-Type: application/json" \
      -d '{ "action": "bamboohr_list_employees", "query": { "page_size": 25 } }'
    ```
  </Step>
</Steps>

<Warning>
  A synced read resolves by `params_hash`. The `action`, `query`, `body`, and `headers` must match what was used on the write, or it won't find the run. Pagination keys are stripped before hashing.
</Warning>

## Sync metadata

The `datasync` block tells you the state of the stored data:

| Field              | Meaning                                               |
| ------------------ | ----------------------------------------------------- |
| `synced_at`        | When the data was written                             |
| `sync_expires_at`  | When the stored data expires                          |
| `last_full_run_id` | The run that produced the readable data               |
| `params_hash`      | Hash of the canonical params that identifies this run |

## When to use it

* The same provider data is read repeatedly and tolerates being slightly stale.
* You want predictable read latency that doesn't depend on the provider.

For data that must be live on every call, use a normal [Actions API](/platform/api-reference/actions/make-an-rpc-call-to-an-action) call without `sync`.

## Reference

<CardGroup cols={2}>
  <Card title="Make an RPC call" icon="bolt" href="/platform/api-reference/actions/make-an-rpc-call-to-an-action">
    The `sync=true` write parameter.
  </Card>

  <Card title="Read synced data" icon="rotate" href="/platform/api-reference/actions/read-synced-action-data-from-the-datasync-index">
    The `/actions/rpc/synced` read endpoint.
  </Card>
</CardGroup>
