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

# REST Call Jobs

export const schema = {
  "type": "object",
  "title": "REST Call",
  "description": "Run arbitrary REST/HTTP/Solr command",
  "required": ["id", "callParams", "type"],
  "properties": {
    "id": {
      "type": "string",
      "title": "ID",
      "maxLength": 128,
      "pattern": "^[A-Za-z0-9_\\-]+$"
    },
    "hidden": {
      "type": "boolean",
      "title": "Hidden",
      "description": "Objects marked as hidden will only be returned in the API with hidden=true",
      "hints": ["hidden"]
    },
    "callParams": {
      "type": "object",
      "title": "Call Parameters",
      "required": ["uri", "method"],
      "properties": {
        "uri": {
          "type": "string",
          "title": "Endpoint URI"
        },
        "method": {
          "type": "string",
          "title": "Call method",
          "description": "One of GET, POST, PUT, or DELETE",
          "enum": ["get", "put", "post", "delete"]
        },
        "queryParams": {
          "type": "object",
          "title": "Query parameters",
          "properties": {},
          "additionalProperties": {
            "type": "string"
          }
        },
        "headers": {
          "type": "object",
          "title": "Request protocol headers",
          "properties": {},
          "additionalProperties": {
            "type": "string"
          }
        },
        "entity": {
          "type": "string",
          "title": "Request entity (as string)",
          "hints": ["code", "lengthy"]
        }
      }
    },
    "type": {
      "type": "string",
      "enum": ["rest-call"],
      "default": "rest-call",
      "hints": ["readonly"]
    }
  },
  "additionalProperties": false,
  "category": "Other",
  "categoryPriority": 1,
  "unsafe": false
};

export const SchemaParamFields = ({schema}) => {
  const sanitize = str => {
    if (typeof str !== "string") return str;
    return str.replace(/^"(.*)"$/s, "$1").replace(/\\/g, "").replace(/"/g, "'");
  };
  const formatDescription = str => {
    const s = sanitize(str);
    return (/[.!?]\)*$/).test(s) ? s : `${s}.`;
  };
  const {description, properties = {}, required: requiredProps = []} = schema;
  const visibleProps = useMemo(() => Object.entries(properties).filter(([, prop]) => !prop.hints?.includes("hidden")), [properties]);
  return <div>
      {description && <p>{formatDescription(description)}</p>}

      {visibleProps.map(([name, prop]) => {
    const isRequired = requiredProps.includes(name);
    const hasDefault = prop.default !== undefined;
    const rawDefault = prop.default;
    const isComplexDefault = hasDefault && (typeof rawDefault === "object" || typeof rawDefault === "string" && (rawDefault.length > 20 || rawDefault.includes('"')));
    const fieldProps = {
      key: name,
      body: prop.title || name,
      type: prop.type,
      ...prop.title && ({
        post: [<><span className="text-stone-400 dark:text-stone-500">API property: </span>{name}</>]
      }),
      ...isRequired && ({
        required: true
      }),
      ...!isComplexDefault && hasDefault ? {
        default: sanitize(String(rawDefault))
      } : {}
    };
    const isObject = prop.type === "object" && prop.properties;
    const isArrayOfObjects = prop.type === "array" && prop.items?.type === "object" && prop.items.properties;
    return <ParamField {...fieldProps}>
            {prop.description && <p>{formatDescription(prop.description)}</p>}

            {isComplexDefault && <div className="flex">
                <p>
                  <strong>Default:</strong>
                </p>
                <pre className="!my-0">
                  <code>
                    {JSON.stringify(rawDefault, null, 2)}
                  </code>
                </pre>
              </div>}

            {isArrayOfObjects && <div className="flex">
              <p>
                <strong>Object attributes:</strong>
              </p>
              <pre className="!my-0">
                <code>
                  {'{\n'}
                  {Object.entries(prop.items.properties).map(([iname, iprop]) => <>
                      {`  ${iname}`}
                      {prop.items?.required?.includes(iname) && <span style={{
      color: 'red'
    }}> required</span>}
                      {`: {\n    display name: ${sanitize(iprop.title || '')}\n    type: ${iprop.type}\n  }\n`}
                    </>)}
                  {'}'}
                </code>
              </pre>
              </div>}

            {isObject && <Expandable title="properties">
                <SchemaParamFields schema={{
      properties: prop.properties,
      required: prop.required
    }} />
              </Expandable>}
          </ParamField>;
  })}
    </div>;
};

export const LwTemplate = ({title = "Key questions to get you started", icon = "sparkles", cta = "Powered by Agent Studio", linkHref = "https://lucidworks.com/demo/?utm_source=docs&utm_medium=referral&utm_campaign=docs_cta_ai"}) => {
  const [isLoaded, setIsLoaded] = useState(false);
  useEffect(() => {
    const timer = setTimeout(() => {
      setIsLoaded(true);
    }, 500);
    return () => clearTimeout(timer);
  }, []);
  return <div className="lw-template-container">
      <Card title={title} icon={icon}>
        {isLoaded && <span dangerouslySetInnerHTML={{
    __html: `<lw-template id="a029c1a9-28be-427e-b0e1-5d918920246a"></lw-template
            >`
  }} />}
        <Link href={linkHref} className="agent-studio-link text-left text-gray-600 gap-2 dark:text-gray-400 text-sm font-medium flex flex-row items-center hover:text-primary dark:hover:text-primary-light group-hover:text-primary group-hover:dark:text-primary-light">Powered by Lucidworks Agent Studio</Link>
      </Card>
    </div>;
};

[localhost link]: http://localhost:3000/docs/4/fusion-server/reference/jobs/rest-call

[mintlify link]: https://doc.lucidworks.com/docs/4/fusion-server/reference/jobs/rest-call

[old doc.lw link]: https://doc.lucidworks.com/fusion/5.9/384

A versatile job type that runs an arbitrary REST/HTTP/Solr command.

<LwTemplate />

REST jobs can call external systems using:

* any HTTP or HTTPS request: `<http-protocol>://<path>`; requires JWT header.
* a Solr request: `solr://COLLECTION_NAME/…​`; authentication is handled.
* a Fusion service request: `extservice://SERVICE_NAME/<path>`; authentication is handled.

For example, you can configure this type of job to delete your old signals data:

1. Navigate to **Collections** > **Jobs**.

2. Click **Add** and select **REST Call**.\
   The REST Call job configuration panel appears.

3. Enter an arbitrary ID for this job, such as "Delete-old-signals".

4. Enter the following endpoint URI, substituting the name of your signals collection for `signalsCollectionName`:

   ```
   solr://signalsCollectionName/update
   ```

5. In the **Call Method** field, select "post".

6. Under **Query Parameters**, enter the property name "wt" with the property value "json".

7. In the **Request entity (as string)** field, enter the following:

   ```xml theme={"dark"}
   <root><delete><query>timestamp_tdt:[* TO NOW-2WEEKS]</query></delete><commit /></root>
   ```

See [Working with Dates](https://solr.apache.org/guide/8_6/working-with-dates.html) for details about date formatting.\
Your job configuration should look similar to this:

<img src="https://mintcdn.com/lucidworks/vupE2UCZdg04NdXx/assets/images/4.2/signals-delete-job.png?fit=max&auto=format&n=vupE2UCZdg04NdXx&q=85&s=b9fead537a4ecf27ca286d4ac6b10e86" alt="Signals delete job configuration" width="1758" height="1329" data-path="assets/images/4.2/signals-delete-job.png" />

<Tip>
  You can configure a schedule for this job at **System** > **Scheduler**.
</Tip>

<SchemaParamFields schema={schema} />
