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

# Create a folder

> Make a folder in a workspace's media library.

> [!NOTE]
>
> Needs `folders:create`, and a role in the workspace that can add media. See [Permissions](/docs/essentials/authentication.md#permissions).

Makes a folder at the top of the library, or in another folder of the same workspace with `parent_id`. `color` is a hex color; left out, it is `#4F46E5`. Send the answer's `id` as `folder_id` on [Upload a file](/docs/api-reference/media/upload-file.md) or [Import media from links](/docs/api-reference/media/upload-url.md) to put files in it.

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `folders:create`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't add media. | No. |
| 422 | | No `name`, a `color` that isn't a hex color, a workspace the key can't reach, or a `parent_id` that isn't a folder of that workspace. | No: fix the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [List folders](/docs/api-reference/folders/list.md): the folders there are.
* [Update a folder](/docs/api-reference/folders/update.md): rename or move it.


## OpenAPI

````yaml POST /folders
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 12 social networks from your code: posts, media, comments,
    analytics, webhooks and more.
  version: 1.0.0
servers:
  - url: https://postsyncer.com/api/v1
security:
  - bearerAuth: []
tags:
  - name: Workspaces
    description: The workspaces the key can reach.
  - name: Accounts
    description: Connected social accounts, links to connect more, and disconnecting them.
  - name: Posts
    description: Drafts, scheduled and published posts, approvals and a post's history.
  - name: Post settings
    description: A post's auto-plug, comment moderation and contact collection.
  - name: Media
    description: >-
      The media library: file uploads, URL imports, and reading videos and
      social posts' files.
  - name: Folders
    description: Folders that organise the media library.
  - name: Comments
    description: >-
      Comments on your posts: reading, replying, editing, hiding, deleting and
      syncing them.
  - name: Reviews
    description: Google Business Profile reviews and your replies to them.
  - name: Analytics
    description: Workspace, account and post performance.
  - name: Brand
    description: >-
      A workspace's brand: identity, voice, look, accounts, competitors,
      learnings and rules.
  - name: Labels
    description: Labels used to tag posts.
  - name: Campaigns
    description: Campaigns used to group posts.
  - name: Snippets
    description: Saved snippets and hashtag groups to drop into posts.
  - name: Webhooks
    description: Signed webhook endpoints that get your notification events.
  - name: Billing
    description: >-
      The owner's plan, invoices and the links that pay for, change or cancel
      it.
  - name: Team
    description: A workspace's teammates and invitations, and their roles.
  - name: Notifications
    description: >-
      Your bell and notification settings, and the workspace's Slack, Discord
      and Telegram channels.
  - name: Blog-to-social
    description: Blog feeds that turn a workspace's new articles into posts.
  - name: Products
    description: Products the workspace's posts can promote.
  - name: Contacts
    description: People who commented on the workspace's posts, and the lists they are on.
  - name: Profile
    description: 'The key''s user: their name and sign-in email.'
  - name: API keys
    description: 'Your API keys: listing and deleting them.'
  - name: Agent sign-up
    description: >-
      An AI agent signs a person up with a code emailed to them, and gets their
      first key. No key needed.
paths:
  /folders:
    post:
      tags:
        - Folders
      summary: Create a folder
      description: >-
        Needs `folders:create`. Your role in the workspace must also let you add
        media. Makes a folder in a workspace's media library, at the top or in
        another folder of the same workspace. Pass its `id` as `folder_id` on
        uploads.
      operationId: createFolder
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspace_id
                - name
              properties:
                workspace_id:
                  type: integer
                  description: The workspace. It must be one the key can reach.
                name:
                  type: string
                  maxLength: 255
                color:
                  type: string
                  nullable: true
                  default: '#4F46E5'
                  description: A hex color, like `#0EA5E9`.
                parent_id:
                  type: integer
                  nullable: true
                  description: >-
                    A folder of the same workspace to put it in. Left out: the
                    top of the library.
            examples:
              default:
                summary: A top-level folder
                value:
                  workspace_id: 12
                  name: Spring menu
              subfolder:
                summary: A folder in another one
                value:
                  workspace_id: 12
                  name: Latte art
                  color: '#0EA5E9'
                  parent_id: 41
      responses:
        '201':
          description: The folder.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIFolder'
              examples:
                default:
                  summary: A top-level folder
                  value:
                    id: 41
                    uuid: 3f6b2c1e-8d4a-4f7b-9c2e-5a1d0e7b6c43
                    workspace_id: 12
                    name: Spring menu
                    color: '#4F46E5'
                    parent_id: null
                    type: DEFAULT
                subfolder:
                  summary: A folder in another one
                  value:
                    id: 42
                    uuid: 7a1c9e40-2b5d-4c8e-a6f1-0d3b8e2c5f97
                    workspace_id: 12
                    name: Latte art
                    color: '#0EA5E9'
                    parent_id: 41
                    type: DEFAULT
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `folders:create`, its user is inactive, or your role
            in the workspace can't add media.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks folders:create
                  value:
                    message: >-
                      This API key does not have the "folders:create"
                      permission. Edit the key in PostSyncer under Settings →
                      API to grant it.
                role:
                  summary: The role can't add media
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to create media. Ask the workspace owner or a manager
                      to do it, or to change your role.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '422':
          description: >-
            A field is missing or wrong, the workspace isn't one the key can
            reach, or `parent_id` isn't a folder of that workspace.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                name:
                  summary: No name
                  value:
                    message: The name field is required.
                    errors:
                      name:
                        - The name field is required.
                color:
                  summary: Not a hex color
                  value:
                    message: The color field must be a valid hexadecimal color.
                    errors:
                      color:
                        - The color field must be a valid hexadecimal color.
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: 'Workspace #99 is invalid or you do not have access to it.'
                    errors:
                      workspace_id:
                        - >-
                          Workspace #99 is invalid or you do not have access to
                          it.
                parent_id:
                  summary: A folder of another workspace
                  value:
                    message: The selected parent id is invalid.
                    errors:
                      parent_id:
                        - The selected parent id is invalid.
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    APIFolder:
      type: object
      description: A folder of the media library.
      required:
        - id
        - uuid
        - workspace_id
        - name
        - color
        - parent_id
        - type
      properties:
        id:
          type: integer
          description: The folder's id. Uploads and List media take it as `folder_id`.
        uuid:
          type: string
          format: uuid
        workspace_id:
          type: integer
        name:
          type: string
        color:
          type: string
          nullable: true
          description: A hex color, like `#4F46E5`.
        parent_id:
          type: integer
          nullable: true
          description: The folder it is in; null at the top of the library.
        parent:
          type: object
          nullable: true
          description: >-
            Get folder and Update folder only: the folder it is in (without its
            own `parent`), or null at the top of the library.
          allOf:
            - $ref: '#/components/schemas/APIFolder'
        type:
          type: string
          enum:
            - DEFAULT
            - DEMO
            - UGC
            - HOOK
            - SOUND
            - AI_GENERATED
            - AI_GENERATED_REFERENCE
          description: >-
            Read from the name: the folders PostSyncer makes for its own work
            are `DEMO` ("Product Demos"), `UGC` ("UGC Videos"), `HOOK` ("Hooks
            Videos"), `SOUND` ("Sounds"), `AI_GENERATED` ("AI Generated") and
            `AI_GENERATED_REFERENCE` ("References"). Every other folder is
            `DEFAULT`.
    Error:
      type: object
      description: >-
        An error answer. Every one has `message`, in plain words; some add an
        `error` code and fields of their own.
      required:
        - message
      properties:
        message:
          type: string
          description: What went wrong and what to do about it.
        error:
          type: string
          description: >-
            A code a few errors add, such as `rate_limited`. See [Handle
            errors](/essentials/error-handling#answers-with-an-error-code).
    ValidationError:
      type: object
      description: '422: the request didn''t pass validation, and nothing changed.'
      required:
        - message
        - errors
      properties:
        message:
          type: string
          description: >-
            The first error and, when there are more, how many: `(and 1 more
            error)`, `(and 2 more errors)`.
        errors:
          type: object
          description: >-
            The messages, by field. A field inside a list is named with dots:
            `accounts.0.id`.
          additionalProperties:
            type: array
            items:
              type: string
  responses:
    Unauthorized401:
      description: No API key, or not a valid one.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            unauthenticated:
              summary: No valid API key
              value:
                message: Unauthenticated.
    RateLimited429:
      description: >-
        More than 60 requests in a minute from this key's user (the API and the
        MCP server share the count). Wait `Retry-After` seconds.
      headers:
        Retry-After:
          description: Seconds until requests are allowed again.
          schema:
            type: integer
        X-RateLimit-Limit:
          description: Requests allowed a minute.
          schema:
            type: integer
        X-RateLimit-Remaining:
          description: Requests left this minute.
          schema:
            type: integer
        X-RateLimit-Reset:
          description: When requests are allowed again, as a Unix timestamp.
          schema:
            type: integer
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            too_many_attempts:
              summary: Too many requests
              value:
                message: Too Many Attempts.
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.