> 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

# UpdateSection

# Package: onlinePrograms

# Namespace: SectionsService

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

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

## Introduction

Updates a section.

Each time the section is updated, `revision` increments by 1. The current `revision` must be passed when updating the section. This ensures you're working with the latest section and prevents unintended overwrites.

Use this method to update section content and settings. To reorder a section, call [Move Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/move-section.md).

---

## REST API

### Schema

```
 Method: updateSection
 Description: Updates a section.  Each time the section is updated, `revision` increments by 1. The current `revision` must be passed when updating the section. This ensures you're working with the latest section and prevents unintended overwrites.  Use this method to update section content and settings. To reorder a section, call [Move Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/move-section.md).
 URL: https://www.wixapis.com/online-programs/v3/sections/{section.id}
 Method: PATCH
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  section.id, section.revision
 Method parameters: 
   param name: section | type: Section | description: A section groups related steps within an online program.  Sections have no separate draft or publish lifecycle. They can be reordered and made available after a delay counted from the program's start date for scheduled programs, or from the participant's enrollment date for self-paced programs.  
        - name: id | type: string | description: Section GUID. | required: true | read-only: true | validation: format GUID
        - name: revision | type: string | description: Revision number, which increments by 1 each time the section is updated. To prevent conflicting changes, the current `revision` must be passed when updating the section. | required: true | read-only: true | validation: format int64
        - 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: UpdateSectionResponse
  - name: section | type: Section | description: Updated section.  
     - name: id | type: string | description: Section GUID.  | read-only: true | validation: format GUID
     - name: revision | type: string | description: Revision number, which increments by 1 each time the section is updated. To prevent conflicting changes, the current `revision` must be passed when updating the section.  | read-only: true | validation: format int64
     - name: createdDate | type: string | description: Date and time the section was created.  | read-only: true | validation: format date-time
     - name: updatedDate | type: string | description: Date and time the section was last updated.  | read-only: true | validation: format date-time
     - 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.  | read-only: true | validation: format GUID, immutable
     - name: description | type: Description | description: Section title.  
        - name: title | type: string | description:   | validation: maxLength 500
     - name: totalSteps | type: integer | description: Total number of steps in the section.  | read-only: true | validation: format int32
     - name: ordering | type: number | description: Position rank used to order sections within a program. To reorder sections, call Move Section.  | read-only: true 
     - 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


```

### Examples

### Update a section
Updates a section title.

```curl
curl -X PATCH \
'https://www.wixapis.com/online-programs/v3/sections/3b2734ad-62c9-4def-987f-5539533f7abc' \
-H 'Authorization: <AUTH>' \
-H 'Content-Type: application/json' \
-d '{
  "section": {
    "id": "3b2734ad-62c9-4def-987f-5539533f7abc",
    "revision": "1",
    "description": {
      "title": "Section 1 clone for docs"
    }
  },
  "fieldMask": {
    "paths": [
      "description.title"
    ]
  }
}'
```

---

## JavaScript SDK

### Schema

```
 Method: wixClientAdmin.onlinePrograms.sections.updateSection(_id, options)
 Description: Updates a section.  Each time the section is updated, `revision` increments by 1. The current `revision` must be passed when updating the section. This ensures you're working with the latest section and prevents unintended overwrites.  Use this method to update section content and settings. To reorder a section, call [Move Section](https://dev.wix.com/docs/api-reference/business-management/online-programs/sections/move-section.md).
 # Note: If the parameter `a.b` is listed under required parameters, `b` is only required if `a` is also present.
 Required parameters:  _id, options.section.revision
 Method parameters: 
   param name: _id | type: string | description: Section GUID. | required: true | validation: format GUID
   param name: options | type: UpdateSectionOptions  none  
        - name: section | type: Section | description: Section to update. Include `section.id`, `section.revision`, and the fields to update.  
           - name: revision | type: string | description: Revision number, which increments by 1 each time the section is updated. To prevent conflicting changes, the current `revision` must be passed when updating the section. | required: true | read-only: true | validation: format int64
           - 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<Section>
  - name: _id | type: string | description: Section GUID.  | read-only: true | validation: format GUID
  - name: revision | type: string | description: Revision number, which increments by 1 each time the section is updated. To prevent conflicting changes, the current `revision` must be passed when updating the section.  | read-only: true | validation: format int64
  - name: _createdDate | type: Date | description: Date and time the section was created.  | read-only: true 
  - name: _updatedDate | type: Date | description: Date and time the section was last updated.  | read-only: true 
  - 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.  | read-only: true | validation: format GUID, immutable
  - name: description | type: Description | description: Section title.  
     - name: title | type: string | description:   | validation: maxLength 500
  - name: totalSteps | type: integer | description: Total number of steps in the section.  | read-only: true | validation: format int32
  - name: ordering | type: number | description: Position rank used to order sections within a program. To reorder sections, call Move Section.  | read-only: true 
  - 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


```

### Examples

### Update a section title
```javascript
import { sections } from "@wix/online-programs";

async function updateSection() {
  const response = await sections.updateSection(
    "3b2734ad-62c9-4def-987f-5539533f7abc",
    {
      section: {
        _id: "3b2734ad-62c9-4def-987f-5539533f7abc",
        revision: "1",
        description: { title: "Updated course materials" },
      },
    },
  );

  return response;
}

/* Promise resolves to:
 * {
 *   "_id": "3b2734ad-62c9-4def-987f-5539533f7abc",
 *   "revision": "2",
 *   "description": { "title": "Updated course materials" }
 * }
 */

```

### updateSection (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 updateSection(_id,options) {
  const response = await myWixClient.sections.updateSection(_id,options);
};
```

---