openapi: 3.0.3
servers:
  - url: https://prod.api.market/api/v1/magicapi/faceswap
info:
  title: "FaceSwap API: Instantaneous replaces face with one another"
  version: 1.0.0
  description: "Seamlessly Swap Faces Between Images in Seconds Instantly create
    captivating face swaps: Our cutting-edge API lets you seamlessly blend two
    faces."
tags:
  - name: FaceSwap
    description: FaceSwap processing endpoints
  - name: visual-recognition
    description: Operations related to visual-recognition
  - name: artificial-intelligence
    description: Operations related to artificial-intelligence
  - name: image-to-image
    description: Operations related to image-to-image
security: {}
components:
  securitySchemes: {}
  schemas:
    FaceSwapRequest:
      type: object
      required:
        - input
      properties:
        input:
          type: object
          required:
            - swap_image
            - target_image
            - target_face_index
          properties:
            swap_image:
              type: string
              format: uri
              description: URL of source image whose face will be extracted.
            target_image:
              type: string
              format: uri
              description: URL of target image where the face will be applied.
            target_face_index:
              type: integer
              description: |
                Index of detected face in target image.
                - `-1` means automatically detect the best face.
              example: -1
      example:
        input:
          swap_image: https://blog.api.market/wp-content/uploads/2024/06/Elon_Musk.png
          target_image: https://blog.api.market/wp-content/uploads/2024/06/Shahrukh_khan.png
          target_face_index: -1
    FaceSwapResponse:
      type: object
      required:
        - request_id
      properties:
        request_id:
          type: string
          description: Unique task identifier used to fetch the result.
      example:
        request_id: edb0210e-176b-403a-a4ec-906764396d21-e2
    ResultRequest:
      type: object
      required:
        - request_id
      properties:
        request_id:
          type: string
          description: Request ID obtained from the create call.
      example:
        request_id: edb0210e-176b-403a-a4ec-906764396d21-e2
    ResultResponse:
      type: object
      required:
        - status
      properties:
        start_time:
          type: string
          nullable: true
          description: Timestamp when processing started.
        status:
          type: string
          enum:
            - pending
            - processing
            - processed
            - failed
          description: Current request state.
        output:
          type: string
          format: uri
          nullable: true
          description: Output image URL if available.
        processed_time:
          type: string
          nullable: true
          description: Timestamp when processing completed.
      example:
        start_time: 12/03/2025, 15:55:35
        status: processed
        output: https://d3tx3wg2jy0sui.cloudfront.net/face_swap/20251203_102532_4111a0e3.jpg
        processed_time: 12/03/2025, 15:55:42
paths:
  /faceswap-image:
    post:
      tags:
        - FaceSwap
      summary: Submit a FaceSwap job
      description: |
        Submit a new request to swap a face in an image.
        The processing is asynchronous — poll `/result` using `request_id`.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/FaceSwapRequest"
            example:
              input:
                swap_image: https://blog.api.market/wp-content/uploads/2024/06/Elon_Musk.png
                target_image: https://blog.api.market/wp-content/uploads/2024/06/Shahrukh_khan.png
                target_face_index: -1
      responses:
        "200":
          description: Successfully queued
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/FaceSwapResponse"
              example:
                request_id: edb0210e-176b-403a-a4ec-906764396d21-e2
        "400":
          description: Invalid input
        "401":
          description: Missing or invalid API key
        "500":
          description: Internal error
    parameters:
      - &a1
        description: API.market API Key
        in: header
        name: x-api-market-key
        value: Please Login/Signup to get an API Key
        required: true
        schema:
          type: string
  /result:
    post:
      tags:
        - FaceSwap
      summary: Retrieve processing result
      description: Poll the status and result of a previously submitted job.
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: "#/components/schemas/ResultRequest"
            example:
              request_id: edb0210e-176b-403a-a4ec-906764396d21-e2
      responses:
        "200":
          description: Result response
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResultResponse"
              example:
                start_time: 12/03/2025, 15:55:35
                status: processed
                output: https://blog.api.market/wp-content/uploads/2025/08/Elon-as-shahrukh-1.jpg
                processed_time: 12/03/2025, 15:55:42
        "401":
          description: Unauthorized
        "404":
          description: Request not found
        "500":
          description: Internal server error
    parameters:
      - *a1
