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

# Using the Saved Schema API

> In addition to using Dromo's intuitive interface, you can also create, edit and delete saved schemas directly via API.

Working with the API allows you to access the complete array of settings and options that Dromo provides.

## The API

Dromo provides a standard REST API for working with schemas. The API provides standard CRUD operations for saved schemas.

You can view the full Saved Schema API reference [here](/api-reference/import-schemas).

## Saved Schema Structure

Schemas have the following fields:

<ResponseField name="id" type="string">
  Schemas are automatically assigned a UUID when they are created.
</ResponseField>

<ResponseField name="name" type="string" required>
  Schemas must have a unique name within your organization.

  Schema names are displayed in the Dromo dashboard.
</ResponseField>

<ResponseField name="settings" type="Settings" required>
  Saved schemas accept the same settings that can be provided to the browser SDK.

  See [Settings](/reference/settings/settings) for more details.
</ResponseField>

<ResponseField name="fields" type="Field[]" required>
  Schemas have an array of fields which also accept the same full set of options as the browser SDK.

  See [Field Object Reference](/fields#field-object-reference) for more details.
</ResponseField>

<ResponseField name="hooks" type="object">
  You can define any or all of the [hooks](/reference/hooks) that Dromo provides using the Saved Schema API.

  The hook function JavaScript source is passed as a string, which must evaluate to a valid JavaScript function. See the [defining hooks section](#defining-hooks) for examples.

  All hooks are optional.

  <Expandable title="Hook Properties">
    <ResponseField name="rowHooks" type="string[]">
      An array of strings defining valid JavaScript [standard row hooks](/reference/hooks#standard-row-hooks).
    </ResponseField>

    <ResponseField name="bulkRowHooks" type="string[]">
      An array of strings defining valid JavaScript [bulk row hooks](/reference/hooks#bulk-row-hooks).
    </ResponseField>

    <ResponseField name="rowDeleteHooks" type="string[]">
      An array of strings defining valid JavaScript [row delete hooks](/reference/hooks#row-delete-hooks).
    </ResponseField>

    <ResponseField name="columnHooks" type="object[]">
      An array of objects defining [column hooks](/reference/hooks#column-hooks).

      Each column hook has a `fieldName` specifying which column the hook will run on, and a `callback` defining a valid JavaScript column hook function.

      <Expandable title="Column Hook Object">
        <ResponseField name="fieldName" type="string" required>
          The field name this hook applies to.
        </ResponseField>

        <ResponseField name="callback" type="string" required>
          Valid JavaScript column hook function.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="stepHooks" type="object[]">
      An array of objects defining [step hooks](/reference/hooks#step-hooks).

      Each step hook has a `type` (one of `"UPLOAD_STEP"`, `"REVIEW_STEP"`, or `"REVIEW_STEP_POST_HOOKS"`) and a `callback` defining a valid JavaScript column hook function.

      <Expandable title="Step Hook Object">
        <ResponseField name="type" type="string" required>
          One of: `"UPLOAD_STEP"`, `"REVIEW_STEP"`, or `"REVIEW_STEP_POST_HOOKS"`
        </ResponseField>

        <ResponseField name="callback" type="string" required>
          Valid JavaScript step hook function.
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="beforeFinishCallback" type="string">
      A string defining a valid JavaScript [before finish callback](/reference/results#the-beforefinish-callback).
    </ResponseField>
  </Expandable>
</ResponseField>

## Defining hooks

Hook functions are defined using strings containing JavaScript source code. The code is evaluated in the end user's browser for standard imports, and using Node.js 18 for headless imports.

All types of function declarations are accepted:

* Anonymous function expression: `function(a, b) { return a + b; }`
* Named function expression: `function sum(a, b) { return a + b; }`
* Arrow function: `(a, b) => { return a + b; }`

<AccordionGroup>
  <Accordion title="Row hook example">
    To define a row hook, you could pass the following to the API's `hooks` parameter:

    <CodeGroup>
      ```javascript theme={null}
      {
        "rowHooks": [
          (record, mode) => {
            record.row.zipCode.value = record.row.zipCode.value.padStart(5, '0');
            return record;
          }
        ]
      }
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Step hook example">
    To define a step hook, you could pass the following to the API's `hooks` parameter:

    <CodeGroup>
      ```javascript theme={null}
      {
        "stepHooks": [
          {
            type: "REVIEW_STEP",
            callback: (instance) => {
              instance.addField({ label: 'Full Name', key: 'fullName' });
            }
          }
        ]
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

## Using saved schemas

Saved schemas can be used [in the browser](/guides/schema-builder) or using the [Headless API](/getting-started/headless).

You can also use the [Saved Schema API](/api-reference/import-schemas) to programmatically create and manage schemas.
