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

# Replace Media

> Replace the file behind a `media_id`, by upload or URL. Messages sent after the replace use the new file; the `media_id` stays the same and the `url` changes. Messages already sent, and AI Outbound requests already accepted, keep the previous file.



## OpenAPI

````yaml PUT /services/core/open_api/v1/media/{id}
openapi: 3.1.0
info:
  title: Oliver Partner API
  description: API for partners to interact with Oliver
  license:
    name: MIT
  version: 1.0.0
servers:
  - url: https://partner-api.getoliver.com
security:
  - bearerAuth: []
paths:
  /services/core/open_api/v1/media/{id}:
    put:
      summary: Replace media
      description: >-
        Replace the file behind a `media_id`, by upload or URL. Messages sent
        after the replace use the new file; the `media_id` stays the same and
        the `url` changes. Messages already sent, and AI Outbound requests
        already accepted, keep the previous file.
      parameters:
        - name: X-Client-Id
          in: header
          required: false
          description: >-
            Optional. Files belong to your API account, not a practice, and work
            at every practice you can send to.
          schema:
            type: string
        - name: id
          in: path
          required: true
          description: The `media_id`, or your `reference_id`.
          schema:
            type: string
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - file
              properties:
                file:
                  type: string
                  format: binary
                  description: A jpeg, png, gif or mp4 file, at most 5 MB.
          application/json:
            schema:
              type: object
              required:
                - url
              properties:
                url:
                  type: string
                  format: uri
                  description: >-
                    An https URL that serves the file directly (redirects aren't
                    followed). Oliver downloads it once and never fetches it
                    again.
                  example: https://partner.example.com/images/rabies-reminder.png
      responses:
        '200':
          description: Replaced
          content:
            application/json:
              schema:
                type: object
                required:
                  - success
                  - data
                properties:
                  success:
                    type: boolean
                  data:
                    $ref: '#/components/schemas/Media'
                  message:
                    type: string
                    nullable: true
        '400':
          description: >-
            Bad Request: a missing, unsupported or oversized file, a URL that
            couldn't be downloaded, or both `file` and `url`. `data.errors`
            names the field (`file` or `url`) and says what was detected.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ValidationError'
        '401':
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeneralError'
        '404':
          description: Not Found
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeneralError'
        '429':
          description: 'Too Many Requests: more than 30 uploads and replaces a minute'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/GeneralError'
components:
  schemas:
    Media:
      type: object
      properties:
        media_id:
          type: string
          description: Pass this as `media_id` in message and AI Outbound content.
          example: 6f1c2b9e-3d4a-4c7e-9b1a-2e5f8d7c6a10
        url:
          type: string
          format: uri
          description: >-
            The file's public URL on Oliver's CDN. A replace gives the file a
            new URL.
          example: >-
            https://cdn.getoliver.com/m/0d3c9a52-8f1e-4b7a-a6c4-5e2f1b9d8c37/image.png
        content_type:
          type: string
          enum:
            - image/jpeg
            - image/png
            - image/gif
            - video/mp4
          description: >-
            Detected from the file itself, not from the upload's headers or file
            name.
        size_bytes:
          type: integer
          example: 182344
        file_name:
          type: string
          nullable: true
          description: The uploaded file's name, or the last part of the imported URL.
          example: rabies-reminder.png
        reference_id:
          type: string
          nullable: true
          example: rabies-reminder
        created_at:
          type: string
          format: date-time
        updated_at:
          type: string
          format: date-time
          description: When the file was last uploaded or replaced.
    ValidationError:
      type: object
      required:
        - success
        - message
        - data
      properties:
        success:
          type: boolean
          example: false
        message:
          type: string
          description: The first error.
          example: content.card.buttons must have at most 4 items
        data:
          type: object
          properties:
            message:
              type: string
            errors:
              type: array
              description: Every offending field.
              items:
                type: object
                properties:
                  field:
                    type: string
                    example: content.card.buttons
                    nullable: true
                    description: >-
                      The offending field, or null for a request-level error
                      such as sending outside the practice's sending hours.
                  message:
                    type: string
                    example: must have at most 4 items
    GeneralError:
      type: object
      required:
        - success
        - message
      properties:
        success:
          type: boolean
        message:
          type: string
        data:
          type: object
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer

````

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