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

# Download an image or template

> A download URL for one image or template. It spends credits.



## OpenAPI

````yaml openapi/magnific-api-v2-stock-openapi.yaml GET /v2/stock/resources/{resource_id}/download
openapi: 3.1.0
info:
  title: Magnific API v2 — Stock
  version: 2.0.0
  description: >-
    Search, read and download stock under `/v2/stock`: images and templates,
    icons and videos (same items, licences and billing as API v1), and music and
    sound effects (free, as on the web).
servers:
  - url: https://api.magnific.com
    description: Production V2
security:
  - magnificApiKey: []
  - bearerAuth: []
tags:
  - name: Videos
    description: >-
      Generate and edit videos. Add `?dry_run=true` to get the price of a
      request first.
paths:
  /v2/stock/resources/{resource_id}/download:
    get:
      tags:
        - Resources
      summary: Download an image or template
      description: |-
        A download link for the resource. Charges the download as on /v1.

        A personal token needs `api:write`.
      operationId: stock_resources_resource_id_download
      parameters:
        - description: Photo, video or PSD resource ID
          example: 30955
          in: path
          name: resource_id
          required: true
          schema:
            type: integer
        - description: >
            Specifies the search query language using the ISO 639-1 (2-letter

            language code) and the ISO 3166-1 (2-letter country code) for
            language variants.

            The API will use "en-US" as a default language for processing if a
            code is not

            provided, or does not exist.
          example: en-US
          in: header
          name: Accept-Language
          required: false
          schema:
            type: string
        - description: >
            Resizes the photo to a specified size while maintaining aspect
            ratio. Accepts a pixel value (100px to 2000px) or 

            keywords small(1000px), medium(1500px), large(2000px), original
            corresponding to standard website sizes.

            The size depends on the image orientation, the longest side of the
            image will be resized to the specified size.

            If not specified, the highest resolution is provided. Applicable
            only to photos.
          example: 2000px
          in: query
          name: image_size
          required: false
          schema:
            $ref: >-
              #/components/schemas/Stockdownload_resource_by_id_image_size_parameter
      responses:
        '200':
          description: OK
          content:
            application/json:
              schema:
                type: object
                properties:
                  data:
                    $ref: >-
                      #/components/schemas/Stockdownload_resource_by_id_200_response_data
                required:
                  - data
              examples:
                download_vector_or_psd:
                  summary: Success - Download resource
                  value:
                    data:
                      filename: Mother-and-daughter.zip
                      url: >-
                        https://downloadscdn5.magnific.com/d/999999/23/99999/8888888/mother-and-daughter.zip?token=exp=1689689298~hmac=1234567890abcde
                download_photo:
                  summary: Success - Download photo
                  value:
                    data:
                      filename: 9126.jpg
                      url: >-
                        https://downloadscdn7.magnific.com/188544/10/9126.jpg?filename=painting-mountain-lake-with-mountain-background&token=exp=1691754014~hmac=36873e9be562d19e95671ec4032feb0c
                download_ai:
                  summary: Success - Download ai resource
                  value:
                    data:
                      filename: lovely-cats.zip
                      url: >-
                        https://downloadscdn5.magnific.com/d/999999/23/99999/8888888/lovely-cats.zip?token=exp=1689689298~hmac=1234567890abcde
                      prompt: >-
                        There are three lovely cats in the picture. They are
                        playing with each other. They are very cute.
        '400':
          description: >-
            `validation_failed`: a parameter is not valid (`details.errors` by
            field, e.g. `query`, `cursor`, `filters.color`).
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '401':
          description: '`unauthenticated`: the token or API key is missing or not valid.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '402':
          description: '`insufficient_credits`: not enough credits for the download.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '403':
          description: >-
            `forbidden`, `upgrade_required` (a premium asset on a plan without
            premium), `restricted_author_content`, `magnific_api_disabled`,
            `key_not_supported` or `api_key_wallet_unavailable`.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '404':
          description: '`not_found`: no such asset.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '422':
          description: >-
            `validation_failed`: the API key is not linked to an active
            subscription, or the tool is not available.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '429':
          description: '`rate_limited`: too many requests or downloads.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '500':
          description: '`internal_error`.'
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
        '503':
          description: >-
            `service_unavailable`: the search engine or a dependency is down;
            retry later.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/StockV2Error'
      security:
        - magnificApiKey: []
        - bearerAuth: []
components:
  schemas:
    Stockdownload_resource_by_id_image_size_parameter:
      oneOf:
        - enum:
            - small
            - medium
            - large
            - original
          type: string
        - pattern: ^(\d{3}|[12]\d{3})px$
          type: string
    Stockdownload_resource_by_id_200_response_data:
      anyOf:
        - $ref: '#/components/schemas/Stockdownload'
        - $ref: '#/components/schemas/Stockai_download'
    StockV2Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: >-
            Stable, for code: `validation_failed`, `unauthenticated`,
            `insufficient_credits`, `forbidden`, `upgrade_required`,
            `not_found`, `rate_limited`, `internal_error`,
            `service_unavailable`...
          example: validation_failed
        message:
          type: string
          description: For people. Never the cause of a server error.
        details:
          type: object
          description: Absent on a server error.
          properties:
            errors:
              type: object
              description: Validation messages by field.
              additionalProperties:
                type: array
                items:
                  type: string
        request_id:
          type: string
    Stockdownload:
      example:
        signed_url: >-
          https://img.b2bpic.net/premium-photo/close-up-cat-resting_1048944-9269194.jpg?t=st=1725276607~exp=1725280207~hmac=1538f1b294fc3a19a19e9f02ceeb6594a9a1e36a900de85d47bbd386e27dddbe
        filename: blackboard-template.zip
        url: https://downloadscdn5.magnific.com/d/1137445/blackboard-template.zip
      properties:
        filename:
          description: Filename of the resource
          example: blackboard-template.zip
          minLength: 1
          type: string
        url:
          example: https://downloadscdn5.magnific.com/d/1137445/blackboard-template.zip
          format: uri
          minLength: 1
          type: string
        signed_url:
          description: The signed URL of the resource preview
          example: >-
            https://img.b2bpic.net/premium-photo/close-up-cat-resting_1048944-9269194.jpg?t=st=1725276607~exp=1725280207~hmac=1538f1b294fc3a19a19e9f02ceeb6594a9a1e36a900de85d47bbd386e27dddbe
          format: uri
          type:
            - string
            - 'null'
      required:
        - filename
        - url
      type: object
    Stockai_download:
      allOf:
        - $ref: '#/components/schemas/Stockdownload'
        - properties:
            prompt:
              description: The used prompt to create this resource
              example: Two cute cats are playing with a ball of wool
              type: string
          required:
            - prompt
          type: object
  securitySchemes:
    magnificApiKey:
      type: apiKey
      in: header
      name: x-magnific-api-key
      description: >-
        Your Magnific API key. [Learn how to obtain an API
        key](https://docs.magnific.com/quickstart)
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: >-
        A personal access token, sent as `Authorization: Bearer <token>`. [How
        to get one](/api-reference/v2/overview#get-a-personal-access-token)

````

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