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

# Set a media file's alt text

> Set or remove the alt text the networks get with a file of the media library.

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

Alt text says what a picture shows, for people who can't see it. A file keeps one, up to 2,000 characters, and every post with the file sends it when the post goes out. These networks take it, each up to its own limit:

| Network | Characters |
| - | - |
| LinkedIn | 4,086 |
| Bluesky | 2,000 |
| Mastodon | 1,500 |
| Discord | 1,024 |
| X, Instagram, Facebook, Threads, Slack | 1,000 |
| Pinterest | 500 |

Longer text is cut to the network's limit, never inside a letter. The other networks don't take alt text.

Send `alt` with the text. It replaces the saved text, and `null` or an empty string removes it. It is the same alt text the app's media library and post editor show, so a change shows there too, and it goes with every post that has the file and hasn't gone out yet. The answer is the file as saved.

To save alt text with a new file, send `alt` with [Upload a file](/docs/api-reference/media/upload-file.md).

```bash cURL theme={null}
curl -X PUT "https://postsyncer.com/api/v1/media/9051/alt" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"alt": "Latte art shaped like a leaf, in a blue cup on a wooden table"}'
```

## Errors

| Status | `error` | When | Retry? |
| - | - | - | - |
| 401 | | No API key, or not a valid one. | No: fix the key. |
| 403 | | The key lacks `media:update`, or its user is inactive. | No: grant it in Settings → API. |
| 403 | | Your role in the workspace can't edit media. | No. |
| 404 | | No file with that id in the workspaces the key can reach. | No. |
| 422 | | `alt` wasn't sent, isn't text, or is over 2,000 characters. Nothing changed. | No: fix the request. |
| 429 | | More than 60 requests a minute. | Yes, after `Retry-After` seconds. |

## Related

* [Get a media file](/docs/api-reference/media/get.md): its `alt` as saved.
* [Upload a file](/docs/api-reference/media/upload-file.md): send `alt` with the file.


## OpenAPI

````yaml PUT /media/{media_id}/alt
openapi: 3.0.3
info:
  title: PostSyncer API
  description: >-
    Post to 14 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:
  /media/{media_id}/alt:
    put:
      tags:
        - Media
      summary: Set a media file's alt text
      description: >-
        Needs `media:update`. Your role in the workspace must also let you edit
        media. Sets or removes the file's alt text: what a picture shows, for
        people who can't see it. Every post with the file sends it when it goes
        out to the networks that take alt text (X, Instagram, Facebook, Threads,
        LinkedIn, Bluesky, Mastodon, Pinterest, Slack and Discord), each cut to
        its own limit. The text sent replaces the saved one, and `null` or an
        empty string removes it. It is the same alt text the app's media library
        and post editor show.
      operationId: updateMediaAlt
      parameters:
        - name: media_id
          in: path
          required: true
          description: The file's id.
          schema:
            type: integer
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
                - alt
              properties:
                alt:
                  type: string
                  nullable: true
                  maxLength: 2000
                  description: >-
                    The alt text, up to 2,000 characters. `null` or an empty
                    string removes it.
            examples:
              default:
                summary: Set it
                value:
                  alt: >-
                    Latte art shaped like a leaf, in a blue cup on a wooden
                    table
              remove:
                summary: Remove it
                value:
                  alt: null
      responses:
        '200':
          description: The file as saved.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/APIMedia'
              examples:
                default:
                  summary: Set
                  value:
                    id: 9051
                    workspace_id: 12
                    folder_id: null
                    name: latte-art.jpg
                    url: https://cdn.postsyncer.com/examples/latte-art.jpg
                    thumb_url: https://cdn.postsyncer.com/examples/latte-art-thumb.jpg
                    medium_url: https://cdn.postsyncer.com/examples/latte-art-medium.jpg
                    mime_type: image/jpeg
                    size: 482113
                    is_processing: false
                    type: image
                    ai_generated_id: null
                    is_reference: false
                    progress: 100
                    alt: >-
                      Latte art shaped like a leaf, in a blue cup on a wooden
                      table
                    duration_seconds: null
                remove:
                  summary: Removed
                  value:
                    id: 9051
                    workspace_id: 12
                    folder_id: null
                    name: latte-art.jpg
                    url: https://cdn.postsyncer.com/examples/latte-art.jpg
                    thumb_url: https://cdn.postsyncer.com/examples/latte-art-thumb.jpg
                    medium_url: https://cdn.postsyncer.com/examples/latte-art-medium.jpg
                    mime_type: image/jpeg
                    size: 482113
                    is_processing: false
                    type: image
                    ai_generated_id: null
                    is_reference: false
                    progress: 100
                    alt: null
                    duration_seconds: null
        '401':
          $ref: '#/components/responses/Unauthorized401'
        '403':
          description: >-
            The key lacks `media:update`, its user is inactive, or your role in
            the workspace can't edit media.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
              examples:
                missing_permission:
                  summary: The key lacks media:update
                  value:
                    message: >-
                      This API key does not have the "media:update" permission.
                      Edit the key in PostSyncer under Settings → API to grant
                      it.
                role:
                  summary: The role can't edit media
                  value:
                    message: >-
                      Your role in the workspace "Halden Coffee" does not allow
                      you to edit media. Ask the workspace owner or an admin to
                      do it, or to change your role.
                inactive_account:
                  summary: The key's user is inactive
                  value:
                    message: Your account is inactive.
        '404':
          $ref: '#/components/responses/NotFound404'
        '422':
          description: >-
            `alt` wasn't sent, isn't text, or is over 2,000 characters. Nothing
            changed.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
              examples:
                missing:
                  summary: No alt sent
                  value:
                    message: The alt field must be present.
                    errors:
                      alt:
                        - The alt field must be present.
                too_long:
                  summary: Over 2,000 characters
                  value:
                    message: The alt field must not be greater than 2000 characters.
                    errors:
                      alt:
                        - >-
                          The alt field must not be greater than 2000
                          characters.
        '429':
          $ref: '#/components/responses/RateLimited429'
components:
  schemas:
    APIMedia:
      type: object
      description: >-
        A file in the media library: what list, get and the uploads give, and
        what posts and comments hold.
      required:
        - id
        - workspace_id
        - folder_id
        - name
        - url
        - mime_type
        - size
        - is_processing
        - type
        - ai_generated_id
        - is_reference
        - progress
        - alt
        - duration_seconds
      properties:
        id:
          type: integer
          description: The file's id. Posts take it in `content[].media`.
        workspace_id:
          type: integer
        folder_id:
          type: integer
          nullable: true
          description: The folder it is in; null at the top of the library.
        name:
          type: string
          description: The file name.
        url:
          type: string
          format: uri
          description: The file itself, at a public link.
        thumb_url:
          type: string
          format: uri
          description: >-
            A picture's small copy (about 400 px on its long edge) for cards and
            lists, or a video's still. Left out until one is made: use `url`
            then. See [Picture
            copies](/api-reference/media/overview#picture-copies).
        medium_url:
          type: string
          format: uri
          description: >-
            A picture's medium copy (about 800 px on its long edge) for large
            tiles and previews. Left out until one is made, and for a picture no
            bigger than 800 px on its long edge, which needs none: use `url`
            then. Videos, GIFs and documents have none.
        mime_type:
          type: string
          nullable: true
          description: The file's type, like `image/jpeg`.
        size:
          type: integer
          nullable: true
          description: The size in bytes.
        is_processing:
          type: boolean
          description: >-
            True while the file is still being made (an AI video, for example).
            It can't go on a post or be deleted until it is ready.
        type:
          type: string
          nullable: true
          enum:
            - image
            - video
            - audio
            - document
            - null
          description: >-
            The kind of file, from `mime_type`: `document` is a PDF, Word or
            PowerPoint file. Null for any other type.
        ai_generated_id:
          type: integer
          nullable: true
          description: Set when PostSyncer's AI made the file; null for uploads.
        is_reference:
          type: boolean
          description: True for a reference picture kept for AI video, not for posting.
        progress:
          type: integer
          description: Always 100.
        alt:
          type: string
          nullable: true
          description: >-
            The alt text, when set: what a picture shows, sent with it to the
            networks that take alt text. Set it with [Set a media file's alt
            text](/api-reference/media/alt).
        duration_seconds:
          type: number
          nullable: true
          description: >-
            A video's or sound's length in seconds, read when it was uploaded.
            Null for pictures and documents, and for files stored before lengths
            were read.
    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.
    NotFound404:
      description: Nothing with that id in the workspaces the key can reach.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
          examples:
            not_found:
              summary: Not found
              value:
                message: Not found.
    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.