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

# Batch Create Apps

> Create multiple apps in a single request.

Creates up to 100 apps in one call. Useful for resellers provisioning apps for multiple customers.

<Warning>
  **Store clientSecret securely.** Each `results[].app.clientSecret` is also available via `GET /apps/{clientId}`, but we recommend persisting it at creation time. Use [Rotate Client Secret](./rotate-client-secret) to issue a new one if needed.
</Warning>

<Note>
  When `continueOnError` is `false` (default), the first item failure aborts the batch and no further items are processed. Set `continueOnError: true` to process all items independently and collect both successes and errors in the response.
</Note>

## Request

<ParamField header="Authorization" type="string" required>
  `Bearer <API_KEY>` from Console > Developers > Workspace API Keys.
</ParamField>

<ParamField header="Content-Type" type="string">
  `application/json`
</ParamField>

<ParamField header="Idempotency-Key" type="string">
  Optional client-generated string (max 255 chars) to safely retry without creating duplicate batches. Scoped per workspace. A key is valid for 24 hours. If the same key is replayed with an identical body, the original response is returned with an `Idempotency-Replayed: true` header. Reusing the same key with a different body returns `409 IDEMPOTENCY_KEY_CONFLICT`.
</ParamField>

## Request Body

<ParamField body="items" type="object[]" required>
  Array of app definitions to create.

  <Expandable title="Item fields">
    <ParamField body="items[].name" type="string" required>
      Display name for the app.
    </ParamField>

    <ParamField body="items[].redirectUris" type="string[]">
      Allowed OAuth redirect URIs for this app.
    </ParamField>

    <ParamField body="items[].webhookConfig" type="object">
      Webhook configuration for this app. See [Update Webhook Config](./update-webhook-config) for field details.
    </ParamField>

    <ParamField body="items[].idempotencyKey" type="string">
      Per-item business key for deduplication within your own system. This is a client-side reference stored on the result — it does **not** replace the HTTP-level `Idempotency-Key` header, which deduplicates the entire batch request.
    </ParamField>
  </Expandable>
</ParamField>

<ParamField body="continueOnError" type="boolean" default="false">
  When `true`, processing continues after an item failure. Failed items appear in `results` with an `error` object. When `false` (default), the first failure aborts the batch.
</ParamField>

## Response

Returns a batch result object.

<ResponseField name="results" type="object[]">
  One entry per input item, in order.

  <Expandable title="Result fields">
    <ResponseField name="results[].app" type="object">
      Present on success. Full App object including `clientSecret` — store it immediately.
    </ResponseField>

    <ResponseField name="results[].error" type="object">
      Present on failure. Contains `code` and `message`.
    </ResponseField>

    <ResponseField name="results[].idempotencyKey" type="string">
      Echo of the per-item `idempotencyKey` if supplied.
    </ResponseField>
  </Expandable>
</ResponseField>

<ResponseField name="successCount" type="number">
  Number of items created successfully.
</ResponseField>

<ResponseField name="errorCount" type="number">
  Number of items that failed.
</ResponseField>

<RequestExample>
  ```bash theme={null}
  curl -X POST \
    -H "Authorization: Bearer sk_workspace_test_..." \
    -H "Content-Type: application/json" \
    -H "Idempotency-Key: 7f3c9a1e-2b4d-4e6f-8a0c-1d2e3f4a5b6c" \
    -d '{
      "items": [
        { "name": "Acme Corp", "redirectUris": ["https://acme.example.com/callback"], "idempotencyKey": "customer-001" },
        { "name": "Beta Ltd",  "redirectUris": ["https://beta.example.com/callback"],  "idempotencyKey": "customer-002" },
        { "name": "Gamma Inc", "idempotencyKey": "customer-003" }
      ],
      "continueOnError": true
    }' \
    "https://sandbox.api.hopae.com/connect/v1/apps/batch"
  ```
</RequestExample>

<ResponseExample>
  ```json theme={null}
  {
    "results": [
      {
        "app": {
          "clientId": "HqTRDIYH",
          "clientSecret": "sh_app_...",
          "name": "Acme Corp",
          "redirectUris": ["https://acme.example.com/callback"],
          "webhookConfig": { "enabled": false, "retryAttempts": 3, "timeoutSeconds": 10, "events": [] }
        },
        "idempotencyKey": "customer-001"
      },
      {
        "app": {
          "clientId": "MkPQRSTU",
          "clientSecret": "sh_app_...",
          "name": "Beta Ltd",
          "redirectUris": ["https://beta.example.com/callback"],
          "webhookConfig": { "enabled": false, "retryAttempts": 3, "timeoutSeconds": 10, "events": [] }
        },
        "idempotencyKey": "customer-002"
      },
      {
        "app": {
          "clientId": "VwXYZ123",
          "clientSecret": "sh_app_...",
          "name": "Gamma Inc",
          "redirectUris": [],
          "webhookConfig": { "enabled": false, "retryAttempts": 3, "timeoutSeconds": 10, "events": [] }
        },
        "idempotencyKey": "customer-003"
      }
    ],
    "successCount": 3,
    "errorCount": 0
  }
  ```
</ResponseExample>
