Mage Blocks API

Manage data loader, transformer, and data exporter blocks.

OpenAPI Specification

mage-ai-blocks-api-openapi.yml Raw ↑
openapi: 3.0.1
info:
  title: Mage Blocks API
  description: REST API exposed by the self-hosted Mage data pipeline app. It covers triggering pipeline runs via API triggers (pipeline schedules), reading pipeline runs, and managing pipelines, blocks, and pipeline schedules. Requests are authenticated with an api_key (query parameter or request body) plus an OAuth token supplied via the OAUTH-TOKEN header or the oauth_token cookie. The default local server runs on port 6789.
  termsOfService: https://www.mage.ai/terms
  contact:
    name: Mage
    url: https://www.mage.ai
  version: '1.0'
servers:
- url: http://localhost:6789/api
  description: Default self-hosted Mage app
- url: https://{host}/api
  description: Custom self-hosted or Mage Pro cloud deployment
  variables:
    host:
      default: localhost:6789
      description: Host and port of the Mage deployment
security:
- ApiKeyAuth: []
  OAuthToken: []
tags:
- name: Blocks
  description: Manage data loader, transformer, and data exporter blocks.
paths:
  /pipelines/{uuid}/blocks:
    post:
      operationId: createBlock
      tags:
      - Blocks
      summary: Create a block in a pipeline
      parameters:
      - name: uuid
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateBlockRequest'
      responses:
        '200':
          description: The created block.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockResponse'
  /pipelines/{uuid}/blocks/{block_uuid}:
    get:
      operationId: readBlock
      tags:
      - Blocks
      summary: Read a block in a pipeline
      parameters:
      - name: uuid
        in: path
        required: true
        schema:
          type: string
      - name: block_uuid
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: A single block.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockResponse'
    put:
      operationId: updateBlock
      tags:
      - Blocks
      summary: Update a block in a pipeline
      parameters:
      - name: uuid
        in: path
        required: true
        schema:
          type: string
      - name: block_uuid
        in: path
        required: true
        schema:
          type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/UpdateBlockRequest'
      responses:
        '200':
          description: The updated block.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockResponse'
    delete:
      operationId: deleteBlock
      tags:
      - Blocks
      summary: Delete a block from a pipeline
      parameters:
      - name: uuid
        in: path
        required: true
        schema:
          type: string
      - name: block_uuid
        in: path
        required: true
        schema:
          type: string
      responses:
        '200':
          description: The deleted block.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/BlockResponse'
components:
  schemas:
    UpdateBlockRequest:
      type: object
      properties:
        block:
          $ref: '#/components/schemas/Block'
    Block:
      type: object
      properties:
        uuid:
          type: string
        name:
          type: string
        type:
          type: string
          enum:
          - data_loader
          - transformer
          - data_exporter
          - scratchpad
          - sensor
          - custom
        language:
          type: string
        upstream_blocks:
          type: array
          items:
            type: string
        downstream_blocks:
          type: array
          items:
            type: string
    BlockResponse:
      type: object
      properties:
        block:
          $ref: '#/components/schemas/Block'
    CreateBlockRequest:
      type: object
      required:
      - block
      properties:
        block:
          type: object
          properties:
            name:
              type: string
            type:
              type: string
            language:
              type: string
  securitySchemes:
    ApiKeyAuth:
      type: apiKey
      in: query
      name: api_key
      description: API key passed as the api_key query parameter or in the request body.
    OAuthToken:
      type: apiKey
      in: header
      name: OAUTH-TOKEN
      description: Decoded OAuth token passed in the OAUTH-TOKEN header, or the raw token passed via the oauth_token cookie.