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

# Update a post

> Updates a post on behalf of its author. Only the attributes sent are changed, and relationships that are not sent are left alone. The author needs a separate permission for each optional setting and relationship they change



## OpenAPI

````yaml https://api.zapnito.com/api/docs/v1/swagger.json put /api/v1/posts/{id}
openapi: 3.0.1
info:
  title: API V1
  version: v1
  description: Zapnito API Documentation
servers:
  - url: https://{host}
    description: Your community domain
    variables:
      host:
        default: your-community.com
        description: Your community domain, for example your-community.com
security: []
tags:
  - name: Health Check
    description: Check that the API is reachable and that your API key is valid
  - name: Identity
    description: Find out which community your API key belongs to
  - name: Users
    description: >-
      Look up the people in your community, update their profile and choose
      which notifications they receive
  - name: Organisations
    description: >-
      Create and update the organisations in your community and manage who
      belongs to them
  - name: Groups
    description: Create groups and manage which users belong to them
  - name: Invitations
    description: Invite people to join your community
  - name: Posts
    description: Create, read and update posts on behalf of your community members
  - name: Contents
    description: >-
      Read the published content of your community and publish, schedule or
      unpublish it
  - name: Channels
    description: List the channels in your community and the content published in each
  - name: Rooms
    description: Create and read the rooms where your community members meet
  - name: Tags
    description: Create tags and apply them to content
  - name: Badges
    description: Create badges and award them to content or to users
  - name: Custom Fields
    description: Read the custom profile fields your community asks its members to fill in
  - name: Third-Party Resources
    description: >-
      Link to resources hosted outside your community so they appear alongside
      your content
  - name: Rest Hooks
    description: >-
      Subscribe a URL to events in your community, so you are told when they
      happen
paths:
  /api/v1/posts/{id}:
    parameters:
      - name: id
        in: path
        required: true
        description: The post id or slug
        schema:
          type: string
    put:
      tags:
        - Posts
      summary: Update a post
      description: >-
        Updates a post on behalf of its author. Only the attributes sent are
        changed, and relationships that are not sent are left alone. The author
        needs a separate permission for each optional setting and relationship
        they change
      operationId: updatePost
      parameters: []
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/PostUpdateRequest'
        required: true
        description: Post payload wrapped in a post object
      responses:
        '200':
          description: The post was updated
          content:
            application/json:
              schema:
                type: object
                properties:
                  post:
                    $ref: '#/components/schemas/Post'
                required:
                  - post
        '401':
          description: >-
            The API key is missing or invalid. The response body is the text
            `HTTP Token: Access denied.`
        '403':
          description: >-
            The author lacks the permission for a setting, or the post failed
            validation
          content:
            application/json:
              examples:
                error:
                  value:
                    errors:
                      premium:
                        - Permission is required
              schema:
                type: object
                properties:
                  errors:
                    type: object
                    additionalProperties:
                      type: array
                      items:
                        type: string
                    example:
                      premium:
                        - Permission is required
                required:
                  - errors
        '404':
          description: >-
            No post in the community has the id, or the post belongs to a
            different author. The response has no body
        '422':
          description: The request failed validation
          content:
            application/json:
              schema:
                oneOf:
                  - type: object
                    properties:
                      errors:
                        type: object
                        additionalProperties:
                          type: array
                          items:
                            type: string
                        example:
                          badge_ids:
                            - Badge 999999 does not exist
                    required:
                      - errors
                  - type: object
                    properties:
                      errors:
                        type: array
                        items:
                          type: string
                        example:
                          - Invalid argument 'user' - expected type User
                    required:
                      - errors
      security:
        - tokenAuth: []
components:
  schemas:
    PostUpdateRequest:
      type: object
      properties:
        post:
          type: object
          properties:
            title:
              type: string
              example: How we improved onboarding
            introduction:
              type: string
              example: A short summary of the post
            content:
              type: string
              example: The full body of the post
            doi:
              type: string
              example: https://doi.org/10.1000/example
            related_content_url:
              type: string
              example: https://example.com/related
            canonical_url:
              type: string
              example: https://example.com/posts/how-we-improved-onboarding
            seo_title:
              type: string
              example: How we improved onboarding
            seo_description:
              type: string
              example: A short summary of the post
            premium:
              type: boolean
              example: false
            editors_pick:
              type: boolean
              example: false
            comments_enabled:
              type: boolean
              example: true
            notifications_enabled:
              type: boolean
              example: true
            room_ids:
              type: array
              items:
                type: integer
              example:
                - 1
            channel_ids:
              type: array
              items:
                type: integer
              example:
                - 1
            badge_ids:
              type: array
              items:
                type: integer
              example:
                - 1
            tag_ids:
              type: array
              items:
                type: integer
              example:
                - 1
            topic_ids:
              type: array
              items:
                type: integer
              example:
                - 1
            author_email:
              type: string
              format: email
              example: jane@example.com
              description: Email address of the existing user who authored the post
            published_at:
              type: string
              format: date-time
              example: '2024-01-01T00:00:00Z'
            content_contributors_attributes:
              type: array
              description: Contributors to add to the post
              items:
                type: object
                properties:
                  user_id:
                    type: integer
                    example: 1
          required:
            - author_email
      required:
        - post
    Post:
      type: object
      properties:
        id:
          type: integer
          example: 1
        type:
          type: string
          example: Post
        status:
          type: string
          example: Complete
        title:
          type: string
          example: How we improved onboarding
        introduction:
          type: string
          nullable: true
          example: A short summary of the post
        content:
          type: string
          nullable: true
          example: The full body of the post
        thumbnail:
          type: string
          nullable: true
          example: https://example.com/thumbnail.png
        author_email:
          type: string
          format: email
          example: jane@example.com
        canonical_url:
          type: string
          example: https://example.com/posts/how-we-improved-onboarding
        internal_url:
          type: string
          example: https://example.com/posts/how-we-improved-onboarding
        doi:
          type: string
          nullable: true
          example: https://doi.org/10.1000/example
        published_at:
          type: string
          nullable: true
          format: date-time
          example: '2024-01-01T00:00:00Z'
          description: When the post was published. Null for a draft or scheduled post
        scheduled_at:
          type: string
          nullable: true
          format: date-time
          example: '2024-01-01T00:00:00Z'
          description: When the post will be published. Null unless it is scheduled
        created_at:
          type: string
          format: date-time
          example: '2024-01-01T00:00:00Z'
        seo_title:
          type: string
          nullable: true
          example: How we improved onboarding
        seo_description:
          type: string
          nullable: true
          example: A short summary of the post
        is_draft:
          type: boolean
          example: false
          description: Whether the post is a draft
        is_scheduled:
          type: boolean
          example: false
          description: Whether the post is scheduled to be published
        is_published:
          type: boolean
          example: true
          description: Whether the post has been published
        comments_enabled:
          type: boolean
          example: true
        downloads_enabled:
          type: boolean
          example: true
        premium:
          type: boolean
          example: false
      required:
        - id
        - type
        - status
        - title
        - content
        - author_email
        - canonical_url
        - created_at
  securitySchemes:
    tokenAuth:
      type: apiKey
      name: Authorization
      in: header
      description: >-
        API authentication using your community API secret. The value below is
        sent as the Authorization header verbatim, so paste the whole header
        value including the prefix: Token token=<api-key>
      x-default: Token token=<api-key>

````

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