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

# action-require-run-with-on-success

> Require a run export when onSuccess is exported in Gadget actions.

| Recommended                                  | Strict                                     | Auto-fixable                                | Scope               |
| -------------------------------------------- | ------------------------------------------ | ------------------------------------------- | ------------------- |
| <Badge color="orange" size="sm">warn</Badge> | <Badge color="red" size="sm">error</Badge> | <Badge color="gray" size="sm">false</Badge> | Gadget action files |

<Tip>Related Gadget documentation: [Gadget docs](https://docs.gadget.dev/guides/actions/code#onsuccess-function)</Tip>

**What the linter reports:**

> onSuccess requires a run export.

## Examples

<Tabs>
  <Tab title="Incorrect">
    ```ts title="api/models/widget/actions/create.ts" theme={null}
    // onSuccess cannot exist without a run export
    export const onSuccess: ActionOnSuccess = async ({ record }) => {
      await doSomething(record);
    };
    ```
  </Tab>

  <Tab title="Correct">
    ```ts title="api/models/widget/actions/create.ts" theme={null}
    // run must be defined alongside onSuccess
    export const run: ActionRun = async ({ params }) => {};
    export const onSuccess: ActionOnSuccess = async ({ record }) => {
      await doSomething(record);
    };
    ```
  </Tab>
</Tabs>
