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

# Update media asset

> Update media asset metadata. Requires a private API key.



## OpenAPI

````yaml https://api.marblecms.com/openapi.json patch /v1/media/{id}
openapi: 3.1.0
info:
  title: Marble API
  version: 1.0.0
  description: A headless CMS API for managing and delivering content programmatically.
servers:
  - url: https://api.marblecms.com
    description: Production
security:
  - apiKey: []
paths:
  /v1/media/{id}:
    patch:
      tags:
        - Media
      summary: Update media asset
      description: Update media asset metadata. Requires a private API key.
      parameters:
        - schema:
            type: string
            example: cryitfjp1234jl04vdnycek8
            description: Media asset ID
          required: true
          description: Media asset ID
          name: id
          in: path
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateMediaBody'
      responses:
        '200':
          description: Media asset updated successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaResponse'
        '400':
          description: Invalid request body
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '403':
          description: Public API key used for write operation
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Forbidden'
        '404':
          description: Media asset not found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/NotFound'
        '500':
          description: Server error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ServerError'
components:
  schemas:
    UpdateMediaBody:
      type: object
      properties:
        name:
          type: string
          minLength: 1
          example: Updated hero image
        alt:
          type: string
          nullable: true
          example: Dashboard with a post editor open
    MediaResponse:
      type: object
      properties:
        media:
          $ref: '#/components/schemas/Media'
      required:
        - media
    Error:
      type: object
      properties:
        error:
          type: string
          example: Invalid query parameters
        details:
          type: array
          items:
            type: object
            properties:
              field:
                type: string
                example: limit
              message:
                type: string
                example: Expected number, received string
            required:
              - field
              - message
        message:
          type: string
          example: Validation failed
      required:
        - error
    Forbidden:
      type: object
      properties:
        error:
          type: string
          example: Forbidden
        message:
          type: string
          example: >-
            Write operations require a private API key (msk_...). Public keys
            are read-only.
      required:
        - error
        - message
    NotFound:
      type: object
      properties:
        error:
          type: string
          example: Post not found
        message:
          type: string
          example: The requested resource does not exist
      required:
        - error
        - message
    ServerError:
      type: object
      properties:
        error:
          type: string
          example: Internal server error
        message:
          type: string
          example: Failed to fetch resource
      required:
        - error
    Media:
      type: object
      properties:
        id:
          type: string
          example: cryitfjp1234jl04vdnycek8
        name:
          type: string
          example: Hero image
        url:
          type: string
          format: uri
          example: https://cdn.marblecms.com/media/hero.jpg
        alt:
          type: string
          nullable: true
          example: A dashboard screenshot
        size:
          type: integer
          example: 382019
          description: File size in bytes
        mimeType:
          type: string
          nullable: true
          example: image/jpeg
        width:
          type: integer
          nullable: true
          example: 1600
        height:
          type: integer
          nullable: true
          example: 900
        duration:
          type: integer
          nullable: true
          example: 12000
          description: Duration in milliseconds
        blurHash:
          type: string
          nullable: true
          example: LEHV6nWB2yk8pyo0adR*.7kCMdnj
        type:
          $ref: '#/components/schemas/MediaType'
        createdAt:
          type: string
          format: date-time
          example: '2024-01-15T10:00:00Z'
        updatedAt:
          type: string
          format: date-time
          example: '2024-01-16T12:00:00Z'
      required:
        - id
        - name
        - url
        - alt
        - size
        - mimeType
        - width
        - height
        - duration
        - blurHash
        - type
        - createdAt
        - updatedAt
    MediaType:
      type: string
      enum:
        - image
        - video
        - audio
        - document
  securitySchemes:
    apiKey:
      type: apiKey
      in: header
      name: Authorization
      description: Your Marble API key

````