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

# Create a snippet

> Save a snippet or a hashtag group in a workspace.

> [!NOTE]
>
> Needs `snippets:create`, and a role in the workspace that can create snippets: owners, managers, content managers and content creators can. See [Permissions](/docs/essentials/authentication.md#permissions).

Saves text the team drops into posts from the composer: `kind: "snippet"` for any text, like a sign-off or a link, and `kind: "hashtags"` for a hashtag group. `name` is 1 to 80 characters and `body` 1 to 5,000, both counted after the spaces at the start and end are dropped. Names need not be unique.

Every plan has snippets, Free included. A workspace keeps at most 500, both kinds together: one more is refused with `422` and the message `This workspace has 500 saved snippets, the most it can keep. Delete one to save another.`

The workspace is checked first, then your role, then the body: a role that can't create snippets gets `403` whatever the body says.

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `snippets:create`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't create snippets. | No. |
| 422 | | No `workspace_id`, or one the key can't reach, a `kind` that isn't `snippet` or `hashtags`, an empty or too long `name` or `body`, or a workspace that already keeps 500 snippets. | No: fix the request, or delete a snippet first. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [List snippets](/docs/api-reference/snippets/list.md): the snippets there are.
* [Update a snippet](/docs/api-reference/snippets/update.md): change one.


## OpenAPI

````yaml POST /snippets
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:
  /snippets:
    post:
      tags:
        - Snippets
      summary: Create a snippet
      description: >-
        Needs `snippets:create`. Your role in the workspace must also let you
        create snippets. Saves a snippet or a hashtag group in a workspace.
        Every plan has snippets; a workspace keeps at most 500, both kinds
        together.
      operationId: createSnippet
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - workspace_id
                - kind
                - name
                - body
              properties:
                workspace_id:
                  type: integer
                  description: The workspace. It must be one the key can reach.
                kind:
                  type: string
                  enum:
                    - snippet
                    - hashtags
                  description: >-
                    `snippet` for any saved text, `hashtags` for a hashtag
                    group.
                name:
                  type: string
                  minLength: 1
                  maxLength: 80
                  description: >-
                    A short name for the list. Spaces at the start and end are
                    dropped before it is counted and saved. It need not be
                    unique.
                body:
                  type: string
                  minLength: 1
                  maxLength: 5000
                  description: >-
                    The text that goes into the post. Spaces at the start and
                    end are dropped.
            examples:
              default:
                summary: A hashtag group
                value:
                  workspace_id: 12
                  kind: hashtags
                  name: Spring menu tags
                  body: '#haldencoffee #springmenu #leedscoffee'
              snippet:
                summary: A snippet
                value:
                  workspace_id: 12
                  kind: snippet
                  name: Shop link
                  body: 'Beans for Monday''s roast: haldencoffee.com/shop'
      responses:
        '201':
          description: The snippet.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Snippet'
              examples:
                default:
                  summary: A hashtag group
                  value:
                    id: 301
                    workspace_id: 12
                    kind: hashtags
                    name: Spring menu tags
                    body: '#haldencoffee #springmenu #leedscoffee'
                    created_by: 7
                    created_at: '2030-03-01T10:12:00+00:00'
                    updated_at: '2030-03-01T10:12:00+00:00'
                snippet:
                  summary: A snippet
                  value:
                    id: 302
                    workspace_id: 12
                    kind: snippet
                    name: Shop link
                    body: 'Beans for Monday''s roast: haldencoffee.com/shop'
                    created_by: 7
                    created_at: '2030-03-02T08:40:00+00:00'
                    updated_at: '2030-03-02T08:40:00+00:00'
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `snippets:create`, its user is inactive, or your role
            in the workspace can't create snippets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks snippets:create
                  value:
                    message: >-
                      This API key does not have the "snippets:create"
                      permission. Edit the key in PostSyncer under Settings →
                      API to grant it.
                role:
                  summary: The role can't create snippets
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to create snippets. 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 it already keeps 500 snippets.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                kind:
                  summary: Not a kind
                  value:
                    message: The selected kind is invalid.
                    errors:
                      kind:
                        - The selected kind is invalid.
                name:
                  summary: A name over 80 characters
                  value:
                    message: The name field must not be greater than 80 characters.
                    errors:
                      name:
                        - The name field must not be greater than 80 characters.
                body:
                  summary: No body
                  value:
                    message: The body field is required.
                    errors:
                      body:
                        - The body field is required.
                workspace_id:
                  summary: Not a workspace the key can reach
                  value:
                    message: Invalid workspace ID.
                    errors:
                      workspace_id:
                        - Invalid workspace ID.
                full:
                  summary: The workspace keeps 500 snippets
                  value:
                    message: >-
                      This workspace has 500 saved snippets, the most it can
                      keep. Delete one to save another.
                    errors:
                      snippets:
                        - >-
                          This workspace has 500 saved snippets, the most it can
                          keep. Delete one to save another.
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    Snippet:
      type: object
      description: A saved snippet or hashtag group to drop into posts.
      required:
        - id
        - workspace_id
        - kind
        - name
        - body
        - created_by
        - created_at
        - updated_at
      properties:
        id:
          type: integer
        workspace_id:
          type: integer
        kind:
          type: string
          enum:
            - snippet
            - hashtags
          description: '`snippet` for any saved text, `hashtags` for a hashtag group.'
        name:
          type: string
          maxLength: 80
        body:
          type: string
          maxLength: 5000
        created_by:
          type: integer
          nullable: true
          description: The user who saved it; null once that user is deleted.
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
    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.