> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# BulkCreateSections

# Package: onlinePrograms

# Namespace: SectionsService

# Method link: https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/bulk-create-sections.md

## Permission Scopes:
Manage Online Programs: SCOPE.CHALLENGES.MANAGE

## Introduction

Creates up to 100 sections in a single API call.

All sections in the request must include `programId` and belong to the same program. Set `description.title` for each section title. The stored ordering values are assigned automatically.

A program can contain up to 1,000 sections. This call fails if creating the requested sections would exceed that limit.

To create a single section, call [Create Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/create-section.md).

---

## REST API

### Schema

```
 Method: bulkCreateSections
 Description: Creates up to 100 sections in a single API call.  All sections in the request must include `programId` and belong to the same program. Set `description.title` for each section title. The stored ordering values are assigned automatically.  A program can contain up to 1,000 sections. This call fails if creating the requested sections would exceed that limit.  To create a single section, call [Create Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/create-section.md).
 URL: https://www.wixapis.com/online-programs/v3/bulk/sections/create
 Method: POST
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  sections, sections.programId
 Method parameters: 
   param name: sections | type: array<sections> | description: List of sections to create. Each section must include `programId`, and all sections must belong to the same program. | required: true | validation: minItems 1, maxItems 100
              - name: programId | type: string | description: Program GUID of the parent program. Provide it when creating a section. After creation, this value can't be changed. | required: true | read-only: true | validation: format GUID, immutable
              - name: description | type: Description | description: Section title.  
                 - name: title | type: string | description:   | validation: maxLength 500
              - name: delayInDays | type: integer | description: Number of days before the section becomes available. The count starts from the program's start date for scheduled programs, or from the participant's enrollment date for self-paced ones. Someone joining a scheduled program after it began may find several sections already open. Use `0` for a section available from the start.  | validation: minimum 0, maximum 5000
              - name: extendedFields | type: ExtendedFields | description: Custom field data for the section. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
                 - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
 Return type: BulkCreateSectionsResponse
  - name: results | type: array<BulkSectionResult> | description: Results for the bulk create operation.  
     - name: itemMetadata | type: ItemMetadata | description: Metadata for the bulk operation result.  
        - name: id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  
        - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated.  
        - name: error | type: ApplicationError | description: Details about the error in case of failure.  
           - name: code | type: string | description: Error code.  
           - name: description | type: string | description: Description of the error.  
           - name: data | type: object | description: Data related to the error.  
     - name: action | type: BulkActionType | description: Action associated with the bulk result.  
         - enum: UNKNOWN_ACTION_TYPE, INSERT, UPDATE, DELETE
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Summary of the bulk create operation.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  


```

### Examples

### Create sections in bulk
Creates sections in a single call. All sections must belong to the same program.

```curl
curl -X POST \
'https://www.wixapis.com/online-programs/v3/bulk/sections/create' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "sections": [
    {
      "programId": "f68c8cf0-95aa-4949-984e-efe800ede364",
      "description": {
        "title": "Bulk docs temp"
      },
      "delayInDays": 0
    }
  ]
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.onlinePrograms.sections.bulkCreateSections(sections)
 Description: Creates up to 100 sections in a single API call.  All sections in the request must include `programId` and belong to the same program. Set `description.title` for each section title. The stored ordering values are assigned automatically.  A program can contain up to 1,000 sections. This call fails if creating the requested sections would exceed that limit.  To create a single section, call [Create Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/create-section.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  sections, sections.programId
 Method parameters: 
   param name: sections | type: array<array> | description: List of sections to create. Each section must include `programId`, and all sections must belong to the same program. | required: true | validation: minItems 1, maxItems 100
              - name: programId | type: string | description: Program GUID of the parent program. Provide it when creating a section. After creation, this value can't be changed. | required: true | read-only: true | validation: format GUID, immutable
              - name: description | type: Description | description: Section title.  
                 - name: title | type: string | description:   | validation: maxLength 500
              - name: delayInDays | type: integer | description: Number of days before the section becomes available. The count starts from the program's start date for scheduled programs, or from the participant's enrollment date for self-paced ones. Someone joining a scheduled program after it began may find several sections already open. Use `0` for a section available from the start.  | validation: minimum 0, maximum 5000
              - name: extendedFields | type: ExtendedFields | description: Custom field data for the section. [Extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md) must be configured in the app dashboard before they can be accessed with API calls.  
                 - name: namespaces | type: object | description: Extended field data. Each key corresponds to the namespace of the app that created the extended fields. The value of each key is structured according to the schema defined when the extended fields were configured.  You can only access fields for which you have the appropriate permissions.  Learn more about [extended fields](https://dev.wix.com/docs/rest/articles/getting-started/extended-fields.md).  | validation: format map
 Return type: PROMISE<BulkCreateSectionsResponse>
  - name: results | type: array<BulkSectionResult> | description: Results for the bulk create operation.  
     - name: itemMetadata | type: ItemMetadata | description: Metadata for the bulk operation result.  
        - name: _id | type: string | description: Item GUID. Should always be available, unless it's impossible (for example, when failing to create an item).  
        - name: originalIndex | type: integer | description: Index of the item within the request array. Allows for correlation between request and response items.  
        - name: success | type: boolean | description: Whether the requested action was successful for this item. When `false`, the `error` field is populated.  
        - name: error | type: ApplicationError | description: Details about the error in case of failure.  
           - name: code | type: string | description: Error code.  
           - name: description | type: string | description: Description of the error.  
           - name: data | type: object | description: Data related to the error.  
     - name: action | type: BulkActionType | description: Action associated with the bulk result.  
         - enum: UNKNOWN_ACTION_TYPE, INSERT, UPDATE, DELETE
  - name: bulkActionMetadata | type: BulkActionMetadata | description: Summary of the bulk create operation.  
     - name: totalSuccesses | type: integer | description: Number of items that were successfully processed.  
     - name: totalFailures | type: integer | description: Number of items that couldn't be processed.  
     - name: undetailedFailures | type: integer | description: Number of failures without details because detailed failure threshold was exceeded.  


```

### Examples

### Create several sections in one call
```javascript
import { sections } from "@wix/online-programs";

async function bulkCreateSections() {
  const response = await sections.bulkCreateSections([
    {
      programId: "f68c8cf0-95aa-4949-984e-efe800ede364",
      description: { title: "Getting started" },
      delayInDays: 0,
    },
    {
      programId: "f68c8cf0-95aa-4949-984e-efe800ede364",
      description: { title: "Practice activities" },
      delayInDays: 7,
    },
  ]);

  return response;
}

/* Promise resolves to:
 * {
 *   "results": [
 *     { "itemMetadata": { "originalIndex": 0, "success": true, "_id": "1cd37b59-9cb3-488a-b406-202bffb5dd2e" }, "action": "INSERT" },
 *     { "itemMetadata": { "originalIndex": 1, "success": true, "_id": "38e98fe9-0c68-4a40-8974-2d02881eb92e" }, "action": "INSERT" }
 *   ],
 *   "bulkActionMetadata": { "totalSuccesses": 2, "totalFailures": 0, "undetailedFailures": 0 }
 * }
 */

```

### bulkCreateSections (self-hosted)
Self-hosted SDK calls require you to [create a client](https://dev.wix.com/docs/sdk/articles/work-with-the-sdk/about-the-wix-client.md).

```javascript
import { createClient } from '@wix/sdk';
import { sections } from '@wix/online-programs';
// Import the auth strategy for the relevant access type
// Import the relevant host module if needed

const myWixClient = createClient ({
  modules: { sections },
  // Include the auth strategy and host as relevant
});


async function bulkCreateSections(sections) {
  const response = await myWixClient.sections.bulkCreateSections(sections);
};
```

---