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

# Create a media upload

> Create a media upload for an event cover image. The response carries a presigned URL: send the raw file bytes with a PUT request within a minute, using exactly the headers returned. Once the file is stored, pass the returned key as <code>media[0].key</code> when creating or updating an event within an hour; an image that is not attached by then is discarded. <h3>OAuth</h3>Required scopes: <code>events</code>



## OpenAPI

````yaml /assets/openapi.json post /events/v1/media
openapi: 3.0.2
info:
  title: Spacebring
  version: 1.0.0
  termsOfService: https://www.spacebring.com/terms
servers:
  - url: https://api.spacebring.com
security: []
paths:
  /events/v1/media:
    post:
      tags:
        - Events
      summary: Create a media upload
      description: >-
        Create a media upload for an event cover image. The response carries a
        presigned URL: send the raw file bytes with a PUT request within a
        minute, using exactly the headers returned. Once the file is stored,
        pass the returned key as <code>media[0].key</code> when creating or
        updating an event within an hour; an image that is not attached by then
        is discarded. <h3>OAuth</h3>Required scopes: <code>events</code>
      operationId: createEventMedia
      parameters:
        - in: header
          name: spacebring-network-id
          schema:
            type: string
            format: uuid
          required: false
          description: >-
            The id of the network. Required when using bearer token
            authentication
      requestBody:
        $ref: '#/components/requestBodies/createEventMedia'
      responses:
        '201':
          description: Created
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/createEventMedia'
        '400':
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/responseError'
      security:
        - BasicAuth: []
        - OAuth2:
            - events
components:
  requestBodies:
    createEventMedia:
      content:
        application/json:
          schema:
            type: object
            properties:
              media:
                type: object
                properties:
                  mimeType:
                    type: string
                    enum:
                      - image/gif
                      - image/jpeg
                      - image/png
                      - image/webp
                    description: MIME type of the file to upload.
                  size:
                    type: integer
                    minimum: 0
                    exclusiveMinimum: true
                    maximum: 5242880
                    description: >-
                      Size of the file in bytes. The upload is rejected when the
                      body length differs.
                required:
                  - mimeType
                  - size
                description: File to upload.
            required:
              - media
      required: true
  schemas:
    createEventMedia:
      type: object
      properties:
        media:
          type: object
          properties:
            key:
              type: string
              description: >-
                Storage key of the media file. Pass it as media[0].key when
                creating or updating an event.
            mimeType:
              type: string
              enum:
                - image/gif
                - image/jpeg
                - image/png
                - image/webp
              description: MIME type of the image file.
            size:
              type: integer
              minimum: -9007199254740991
              maximum: 9007199254740991
              description: Size of the image file in bytes.
            status:
              type: string
              enum:
                - pending
                - uploaded
                - attached
              description: >-
                Upload status. pending: the file has not been received yet.
                uploaded: the file is stored and can be attached to an event.
                attached: an event references the file.
            upload:
              type: object
              properties:
                expirationDate:
                  type: string
                  format: date-time
                  description: ISO timestamp after which the upload URL is rejected.
                headers:
                  type: object
                  properties:
                    Content-Length:
                      type: string
                      description: >-
                        Must equal the size declared when the upload was
                        created.
                    Content-Type:
                      type: string
                      description: >-
                        Must equal the mimeType declared when the upload was
                        created.
                  required:
                    - Content-Length
                    - Content-Type
                  additionalProperties: false
                  description: >-
                    Headers the PUT request must send exactly as given; the
                    signature covers them.
                method:
                  type: string
                  enum:
                    - PUT
                  description: HTTP method of the upload request.
                url:
                  type: string
                  description: Presigned URL to send the raw file bytes to.
              required:
                - expirationDate
                - headers
                - method
                - url
              additionalProperties: false
              description: >-
                How to upload the file. Send the raw bytes as the request body,
                not a multipart form.
          required:
            - key
            - mimeType
            - size
            - status
            - upload
          additionalProperties: false
          description: The created media upload.
      required:
        - media
      additionalProperties: false
    responseError:
      type: object
      properties:
        message:
          type: string
        type:
          type: string
  securitySchemes:
    BasicAuth:
      type: http
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#basic-authentication)
        for how to authorize your requests
      scheme: basic
    OAuth2:
      type: oauth2
      description: >-
        See our [authentication
        documentation](https://www.spacebring.com/docs/api-reference/authentication#oauth2)
        for how to authorize your requests
      flows:
        authorizationCode:
          authorizationUrl: https://api.spacebring.com/oauth2/authorize
          tokenUrl: https://api.spacebring.com/oauth2/token
          refreshUrl: https://api.spacebring.com/oauth2/token
          scopes:
            benefits.readonly: Read benefits and applications
            benefits: Read and write benefits and applications
            community.readonly: Read community companies and memberships
            community: Read and write community companies and memberships
            events.readonly: Read events and tickets
            events: Read and write events and tickets
            feed.readonly: Read feed posts
            feed: Read and write feed posts
            invoices.readonly: Read contracts, credit notes, discounts and invoices
            invoices: Read and write contract, credit notes, discounts and invoices
            locations.readonly: Read locations
            locations: Read and write locations
            plans.readonly: Read plans
            plans: Read and write plans
            resources.readonly: Read resources and bookings
            resources: Read and write resources and bookings
            subscriptions.readonly: Read subscriptions
            subscriptions: Read and write subscriptions
            shop.readonly: Read products and orders
            shop: Read and write products and orders
            support.readonly: Read support tickets
            support: Read and write support tickets
            transactions.readonly: Read transactions
            transactions: Read and write transactions
            visitors.readonly: Read visitors
            visitors: Read and write visitors

````