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

# Upload media library file

> Uploads a file to the media library and
    returns the created media library entry.



## OpenAPI

````yaml /openapi/adm.openapi.en-0.2.2.json post /media_library
openapi: 3.1.0
info:
  description: >
    ## Introduction

    The Data Management APIs comprehensively oversees the **diverse data** used
    by advertising and recommendation systems, ensuring that the Decision API
    runs accurately and efficiently.


    From registering, updating, and deleting campaigns and placements to **log
    and statistics analysis**, it provides the insights necessary for effective
    system operation.


    The resulting data and metrics are used by the Decision API to **optimize ad
    and content decisions**, ultimately boosting the overall performance of the
    advertising and recommendation system.
  title: Data Management APIs
  version: 0.1.3
servers: []
security: []
tags:
  - name: Audience Targeting
  - description: >

      The Audience Management APIs to seamlessly integrate Audience-related
      data.  


      References:

      - [First-Party
      Data](https://docs.aiderx.io/guides/about-a2/en/first-party-data)
    name: Audience
  - description: >
      APIs for collecting user activity data to enhance ad targeting and
      performance optimization.


      Activity Data captures actual user behavior data like product views,
      searches, cart additions, and purchases across all users, regardless of ad
      interactions.


      References:

      - [First-Party
      Data](https://docs.aiderx.io/guides/about-a2/en/first-party-data)
    name: Activity Log
  - description: >

      The Audience Attribute API provides access to audience attribute data.


      References:

      - [Audience
      Targeting](https://docs.aiderx.io/guides/about-a2/en/audience-targeting)
    name: Audience Attribute
  - description: >

      The Audience Segment API provides access to audience segment data.


      References:

      - [Audience
      Targeting](https://docs.aiderx.io/guides/about-a2/en/audience-targeting)
    name: Audience Segment
  - description: The Analytic API provides access to dashboard and A2 metric data.
    name: Analytic
  - description: >

      The Billing API manages billing information.

      A2 is configured to work with the payment systems used by your retail
      platform.


      To integrate payments, first you need to register an external channel.

      For more information about integrating A2 with external channels, check
      out [the External channels
      page](https://docs.aiderx.io/guides/about-a2/en/external-channel).
    name: Billing
  - description: |

      The Campaign API allows you to manage data related to campaigns.

      References:
      - [Campaign](https://docs.aiderx.io/guides/about-a2/en/campaign)
    name: Campaign
  - description: >

      The Creative API provides comprehensive functionalities for managing
      creative assets and related resources.


      References:

      - [Creative](https://docs.aiderx.io/guides/about-a2/en/creative)
    name: Creative
  - description: >

      The Allocation API provides comprehensive functionalities for managing
      allocation and related resources.


      References:

      - [Allocation](https://docs.aiderx.io/guides/about-a2/en/allocation)
    name: Allocation
  - description: >

      The Media Library API provides comprehensive functionalities for managing
      media library and related resources.


      References:

      - [Media Library](https://docs.aiderx.io/guides/about-a2/en/media-library)
    name: Media Library
  - description: >

      The Catalog Management API provides functionalities for managing catalogs
      and related resources.


      References:

      - [First-Party
      Data](https://docs.aiderx.io/guides/about-a2/en/first-party-data)
    name: Catalog
  - description: >

      The Placement Management API provides comprehensive functionalities for
      managing placements and related resources.


      References:

      - [Placement](https://docs.aiderx.io/guides/about-a2/en/placement)
    name: Placement
  - description: >

      Placement Catalog transforms the placement information into a structured
      “advertising product” that can be easily showcased to advertisers.


      References:

      - To be updated
    name: Placement Catalog
  - description: >

      The System APIs allow you to access and manage system-level settings and
      assets, such as logos and configuration values.


      References:

      - [Yield Optimization
      Settings](https://docs.aiderx.io/guides/about-a2/en/yield-optimization)
    name: System
  - description: >

      The Auth and User API provides authentication and user management
      functionalities.


      References:

      - [Account and
      Budget](https://docs.aiderx.io/guides/about-a2/en/account-and-budget)
    name: Auth and User
  - description: |

      The License API provides license management functionalities.
    name: License
paths:
  /media_library:
    post:
      tags:
        - Media Library
      summary: Upload media library file
      description: |-
        Uploads a file to the media library and
            returns the created media library entry.
      operationId: handle_upload_media_media_library_post
      requestBody:
        content:
          multipart/form-data:
            schema:
              $ref: '#/components/schemas/Body_handle_upload_media_media_library_post'
        required: true
      responses:
        '200':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/MediaLibraryReadSchema'
          description: Successful Response
        '422':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/HTTPExceptionResponse'
          description: Unprocessable Content
components:
  schemas:
    Body_handle_upload_media_media_library_post:
      properties:
        cdn_host:
          description: The base URL of the CDN where the media will be accessible
          title: Cdn Host
          type: string
        file:
          description: The media file to be uploaded to the library
          format: binary
          title: File
          type: string
        file_size:
          description: The size of the file in bytes
          title: File Size
          type: integer
        height:
          description: The height of the media in pixels
          title: Height
          type: integer
        mime:
          description: The MIME type of the media file (e.g., image/jpeg, video/mp4)
          title: Mime
          type: string
        owner_id:
          description: The owner's id of media library
          format: uuid
          title: Owner Id
          type: string
        storage:
          description: |-
            The storage backend where the media will be stored.
                    Supported values: 'fs' (filesystem) or 'aws' (Amazon Web Services)
          title: Storage
          type: string
        width:
          description: The width of the media in pixels
          title: Width
          type: integer
      required:
        - file
        - height
        - width
        - mime
        - file_size
        - cdn_host
        - owner_id
        - storage
      title: Body_handle_upload_media_media_library_post
      type: object
    MediaLibraryReadSchema:
      description: Schema for reading media library entity.
      properties:
        cdn_path:
          description: The CDN url from which the media can be accessed
          title: Cdn Path
          type: string
        created_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: The date and time the entity was created.
          title: Created At
        file_size:
          description: The file size of the media
          title: File Size
          type: integer
        filename:
          description: The filename of media library
          title: Filename
          type: string
        height:
          description: The height of the media
          title: Height
          type: integer
        mime:
          description: The mime-type of the media
          title: Mime
          type: string
        'no':
          description: The no of media library
          title: 'No'
          type: integer
        path:
          description: Relative paths stored in the storage
          title: Path
          type: string
        storage:
          description: The storage type where the media is stored
          title: Storage
          type: string
        updated_at:
          anyOf:
            - format: date-time
              type: string
            - type: 'null'
          description: The date and time the entity was last updated.
          title: Updated At
        user_id:
          description: The owner's id of media library
          format: uuid
          title: User Id
          type: string
        width:
          description: The width of the media
          title: Width
          type: integer
      required:
        - user_id
        - filename
        - cdn_path
        - path
        - width
        - height
        - mime
        - file_size
        - storage
        - 'no'
      title: MediaLibraryReadSchema
      type: object
    HTTPExceptionResponse:
      description: HTTPException response model.
      properties:
        detail:
          description: Detailed explanation for the exception
          title: Detail
          type: string
      required:
        - detail
      title: HTTPExceptionResponse
      type: object

````