> For the complete documentation index, see [llms.txt](https://docs.feathery.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.feathery.io/develop/context-api.md).

# Context API

All of these properties are available via [advanced logic](/platform/build-forms/advanced-logic.md), [event handlers](/develop/react/api-guide/form/event-handlers.md), and the [contextRef](/develop/react/api-guide/form/contextref.md) object. Specific events may also have additional properties unique to them. To see these properties, check out the documentation for the corresponding [event handler](/develop/react/api-guide/form/event-handlers.md).

|           Key           |                                                                                                                                                 Type                                                                                                                                                | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| :---------------------: | :-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|        `formName`       |                                                                                                                                               `string`                                                                                                                                              | The name of the form                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|         `formId`        |                                                                                                                                               `string`                                                                                                                                              | The ID of the form                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|         `userId`        |                                                                                                                                               `string`                                                                                                                                              | The ID of the user in the current form session                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|         `fields`        |                                                                                                                                   `{ [fieldKey: string]: Field }`                                                                                                                                   | A mapping that contains all fields on any of your forms. Its key is the field ID and value is a [Field](/develop/context-api/field-object.md) object. Use the Field object to read/write a field value, options, error message, etc.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|   `getStepProperties`   |                                                             `() => { totalSteps: number, stepName: string, previousStepName: string, backgroundColor: hex string, language?: string, hideRules: { elementType: string; rules: {}[] } }`                                                             | <p>Returns useful information about the current step of the form:</p><ul><li>Name of current step</li><li>Name of previous step</li><li>Background color of step</li><li>Total steps in form</li><li>Language code of form if set</li><li>Conditional hide/show rules on step</li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|        `goToStep`       |                                                                                                                                              `function`                                                                                                                                             | If you want to reroute the user to a different step, pass `goToStep` the ID of the new step to route to. For example, `goToStep('new-step')`                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|      `setProgress`      |                                                                                                                    `(number \| { progress?: number; segments ?: number }) => {}`                                                                                                                    | <p>Set the amount of the progress bar on the current step.</p><p></p><p>Pass in either a number from 0 - 100 or if you want a segmented progress bar, you can pass in both the progress amount and the number of segments you want the progress bar to be broken into.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|   `setFormCompletion`   |                                                                                                                                              `function`                                                                                                                                             | Pass in a boolean flag to set the user's completion status for this form.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|      `validateStep`     |                                                                                                                 `(showErrors = true) => { [fieldKey: string]: string \| string[] }`                                                                                                                 | <p>Runs default form validation on the current step. Triggers built-in field validation along with custom validation rules specified from the dashboard. Errors will be shown unless false is passed for showErrors. </p><p><br>Returns an error message per field, or an empty string if the field is valid.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|       `isLastStep`      |                                                                                                                                           `() => boolean`                                                                                                                                           | Returns `True` when the current step is the last step the user needs to complete.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|       `isTestForm`      |                                                                                                                                           `() => boolean`                                                                                                                                           | Returns `True` when the current form is in test mode (and not live).                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|      `collaborator`     |                                                                                               [`Collaborator`](/platform/collaborative-workflows/collaboration.md#collaborator-object-in-logic-rules)                                                                                               | Information about the active collaborator.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `runIntegrationActions` |                                                                                                                                <p></p><p><code>(actionIds: string\[]                                                                                                                                | string,</code><br><code>options: {waitForCompletion?: boolean;multiple?: boolean}) => Promise<{ ok: boolean; error?: string; payload?: any}></code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | <p>Trigger integration actions that have been set up with the <code>Custom Logic</code> trigger. If multiple actions are passed, they will be run in order.</p><p></p><p>If <code>waitForCompletion</code> is true (the default), the returned Promise will resolve with data from the last action once it completes. Otherwise, it will return immediately with no data.<br><br>If <code>multiple</code> is true (defaults to false), you may trigger the same action multiple times for a single submission.</p>                                                                    |
|    `runAIExtraction`    |                                                                                       <p><code>(extractionId: string,</code><br><code>options: {waitForCompletion?: boolean,</code><br><code>pages?: number\[]                                                                                      | number\[]\[],</code><br><code>variantId?: string})</code></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       | <p>Trigger an AI document extraction. <br><br>If <code>waitForCompletion</code> is true, the returned Promise will resolve with data from the last action once it completes. Otherwise, it will return immediately with no data.<br><br>If <code>variantId</code> is specified, the extraction will run with that variant applied.<br><br>If <code>pages</code> is an array of page numbers, the extraction will run on the page numbers specified once. If <code>pages</code> is an array of arrays of page numbers, the extraction will run once on each array of page numbers.</p> |
|   `generateDocuments`   |                                                                                          <p><code>({documentIds: string\[],</code><br><code>download: boolean,</code><br><code>merge: boolean})</code></p>                                                                                          | <p>Trigger document/s to generate envelopes.<br><br>If <code>download</code> is true, after the envelopes are generated the user will be prompted to download them.<br><br>If <code>merge</code> is true, all the pdf documents will be merged into one pdf file in the order specified in <code>documentIds</code>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|      `updateUserId`     |                                                                                                                             `(userId: string, merge?: boolean) => void`                                                                                                                             | Update the user ID of the current session. [Full reference](/develop/react/api-guide/updateuserid.md)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|      `updateTheme`      |                                                                                                                                      `(theme: string) => void`                                                                                                                                      | Update the theme of all embedded forms dynamically                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|        `openUrl`        |                                                                                                                            `async (url: string, target?: string) => void`                                                                                                                           | Flush any pending field updates and then opens up a URL. If target isn't specified, it defaults to `_blank` and opens in a new tab. To open in the same tab, specify `_self` for the target.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|     `setCalendlyUrl`    |                                                                                                                                       `(url: string) => void`                                                                                                                                       | If a [Calendly](https://feathery.io/integrations/calendly) scheduling flow is embedded in your form, you can dynamically update the calendar by calling this function and passing in a new Calendly URL.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|          `cart`         |                                                                                                          [`Cart`](/guides/payment-flow/select-products-or-plans.md#logic-rule-cart-access)                                                                                                          | If the Stripe connector is configured and connected, then the purchase cart is available with a number of properties about the cart and items within it.  See [here](/guides/payment-flow/select-products-or-plans.md#logic-rule-cart-access) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|        `products`       |                                                                                  { \[product\_id: string]: [`Products`](/guides/payment-flow/select-products-or-plans.md#logic-rule-stripe-purchasable-products) }                                                                                  | If the Stripe connector is configured and connected, then the purchasable products are available as a hash.  See [here](/guides/payment-flow/select-products-or-plans.md#logic-rule-stripe-purchasable-products) for details.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
|     `dataHubAction`     | `dataHubAction({ hubId: string, operation: "create" \| "get" \| "update" \| "delete", data?: Record<string, any>, where?: Array<{ entryId: string } \| { fieldId: string, value?: any }>, entryId?: string // deprecated — use where instead }) => Entry \| Entry[] \| { updated: number } \| void` | <p></p><p>If Data Hubs are enabled for your organization and your form has authentication enabled, you can perform data hub actions.</p><p><strong><code>where</code></strong> selects which entries an action applies to. It's a list of conditions that must <em>all</em> match (AND). Each condition is either:</p><ul><li><code>{ entryId: "..." }</code> — the entry with that id, or</li><li><code>{ fieldId: "columnKey", value: ... }</code> — entries where that column exactly equals <code>value</code>.</li><li><strong>get</strong> — returns the matching entries as an array. With no <code>where</code>, every entry is returned.</li><li><strong>create</strong> — pass <code>data</code>; returns the created entry.</li><li><strong>update</strong> — pass <code>data</code> (the column values to set) and <code>where</code> (which entries to update); returns <code>{ updated: \<count> }</code>.</li><li><strong>delete</strong> — pass <code>where</code> (which entries to delete); returns <code>{ deleted: \<count> }</code>.</li></ul> |                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |

#### [Deprecated Context API](/develop/context-api/deprecated-context-api.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.feathery.io/develop/context-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
