{
  "openapi": "3.0.3",
  "info": {
    "title": "Bulk import",
    "description": "Import users into Mosaic in bulk. Upload JSON files with the users, start an import run, track its progress and cancel it if necessary.",
    "version": ""
  },
  "servers": [
    {
      "url": "https://api.sbx.transmitsecurity.io/cis",
      "description": "Sandbox environment"
    },
    {
      "url": "https://api.transmitsecurity.io/cis",
      "description": "US production environment"
    },
    {
      "url": "https://api.eu.transmitsecurity.io/cis",
      "description": "EU production environment"
    },
    {
      "url": "https://api.ca.transmitsecurity.io/cis",
      "description": "CA production environment"
    },
    {
      "url": "https://api.au.transmitsecurity.io/cis",
      "description": "AU production environment"
    },
    {
      "url": "https://api.gasne1-ts01.transmitsecurity.io/cis",
      "description": "JP production environment"
    }
  ],
  "security": [],
  "paths": {
    "/v1/migration/users/files/upload-urls": {
      "post": {
        "description": "Mints one presigned POST payload per file so the client can upload straight to object storage. The signed policy pins the tenant key prefix and a maximum file size.",
        "operationId": "createUserMigrationUploadUrls",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateUserMigrationUploadUrlsInput"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-createUserMigrationUploadUrls",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Upload urls minted",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiUserMigrationUploadUrls"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestHttpError"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConflictHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Create user migration upload urls"
      }
    },
    "/v1/migration/users/files": {
      "get": {
        "description": "Lists the tenant's currently uploaded migration files and how many of its file slots are held.",
        "operationId": "getUserMigrationFiles",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-getUserMigrationFiles",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Files fetched",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiUserMigrationFiles"
                    }
                  }
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Get user migration files"
      },
      "delete": {
        "description": "Deletes every migration file the tenant has uploaded.",
        "operationId": "deleteUserMigrationFiles",
        "parameters": [],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-deleteUserMigrationFiles",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Files deleted",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiUserMigrationDeletedFiles"
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConflictHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Delete user migration files"
      }
    },
    "/v1/migration/users/files/{file_name}": {
      "delete": {
        "description": "Deletes one uploaded migration file.",
        "operationId": "deleteUserMigrationFile",
        "parameters": [
          {
            "name": "file_name",
            "required": true,
            "in": "path",
            "description": "Name of the uploaded file",
            "schema": {
              "title": "File name",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-deleteUserMigrationFile",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "File deleted",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiUserMigrationDeletedFiles"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundHttpError"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConflictHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Delete user migration file"
      }
    },
    "/v1/migration/users/runs": {
      "post": {
        "description": "Starts a migration run for the requested uploaded files.",
        "operationId": "createUserMigrationRun",
        "parameters": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ApiCreateUserMigrationRunInput"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiCreatedResponse-createUserMigrationRun",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Run created",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiCreatedUserMigrationRun"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestHttpError"
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundHttpError"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConflictHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Create a user migration run"
      }
    },
    "/v1/migration/users/runs/{run_id}": {
      "get": {
        "description": "Returns the progress of a migration run and a report link for each completed file.",
        "operationId": "getUserMigrationRun",
        "parameters": [
          {
            "name": "run_id",
            "required": true,
            "in": "path",
            "description": "Identifier of the migration run",
            "schema": {
              "title": "Run id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-getUserMigrationRun",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Run fetched",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiUserMigrationRun"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Get a user migration run"
      }
    },
    "/v1/migration/users/runs/{run_id}/cancel": {
      "post": {
        "description": "Stops a running migration run. Work already in progress finishes, and every file still gets a report.",
        "operationId": "cancelUserMigrationRun",
        "parameters": [
          {
            "name": "run_id",
            "required": true,
            "in": "path",
            "description": "Identifier of the migration run",
            "schema": {
              "title": "Run id",
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "title": "ApiOkResponse-cancelUserMigrationRun",
                  "type": "object",
                  "required": [
                    "result"
                  ],
                  "description": "Run cancelled",
                  "properties": {
                    "result": {
                      "$ref": "#/components/schemas/ApiCancelledUserMigrationRun"
                    }
                  }
                }
              }
            }
          },
          "404": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundHttpError"
                }
              }
            }
          },
          "409": {
            "description": "",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ConflictHttpError"
                }
              }
            }
          }
        },
        "security": [
          {
            "AdminAccessToken": []
          }
        ],
        "summary": "Cancel a user migration run"
      }
    }
  },
  "components": {
    "schemas": {
      "CreateUserMigrationUploadUrlsInput": {
        "type": "object",
        "properties": {
          "files": {
            "title": "Files",
            "description": "Names of the files to upload.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "files"
        ]
      },
      "BadRequestHttpError": {
        "type": "object",
        "properties": {
          "message": {
            "example": "Bad request",
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error_code": {
            "type": "number",
            "example": 400
          }
        },
        "required": [
          "message",
          "error_code"
        ]
      },
      "ConflictHttpError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "number"
          }
        },
        "required": [
          "message",
          "error_code"
        ]
      },
      "ApiUserMigrationUploadUrls": {
        "type": "object",
        "properties": {
          "files": {
            "description": "The generated upload endpoints and policies for each requested file",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiUserMigrationUploadUrl"
            }
          }
        },
        "required": [
          "files"
        ]
      },
      "ApiUserMigrationFiles": {
        "type": "object",
        "properties": {
          "files": {
            "description": "Files currently stored for the tenant",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiUserMigrationFile"
            }
          },
          "slots_used": {
            "type": "number",
            "description": "Total file slots currently consumed. This includes both stored files and pending, unused upload URLs."
          },
          "slots_capacity": {
            "type": "number",
            "description": "Maximum number of concurrent file slots the tenant is permitted to hold"
          }
        },
        "required": [
          "files",
          "slots_used",
          "slots_capacity"
        ]
      },
      "ApiUserMigrationDeletedFiles": {
        "type": "object",
        "properties": {
          "deleted": {
            "type": "number",
            "description": "Total number of files successfully deleted"
          }
        },
        "required": [
          "deleted"
        ]
      },
      "NotFoundHttpError": {
        "type": "object",
        "properties": {
          "message": {
            "type": "string"
          },
          "error_code": {
            "type": "number",
            "example": 404
          }
        },
        "required": [
          "message",
          "error_code"
        ]
      },
      "ApiCreateUserMigrationRunInput": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "live",
              "dry_run"
            ],
            "title": "Mode",
            "description": "Controls the execution type. \"live\" provisions users, \"dry_run\" only parses and validates the files"
          },
          "app_id": {
            "type": "string",
            "title": "App ID",
            "description": "The target application the migrated users will be provisioned in"
          },
          "files": {
            "title": "Files",
            "description": "Names of previously uploaded files to process. Defaults to all uploaded files if omitted.",
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        },
        "required": [
          "mode",
          "app_id"
        ]
      },
      "ApiCreatedUserMigrationRun": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "description": "Identifier of the created run"
          },
          "status": {
            "type": "string",
            "description": "Status the run starts in",
            "enum": [
              "running",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "total_files": {
            "type": "number",
            "description": "Number of files the run will process"
          }
        },
        "required": [
          "run_id",
          "status",
          "total_files"
        ]
      },
      "ApiUserMigrationRun": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "description": "Identifier of the run"
          },
          "status": {
            "type": "string",
            "description": "Current status of the run",
            "enum": [
              "running",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "mode": {
            "type": "string",
            "description": "Mode the run was started in",
            "enum": [
              "live",
              "dry_run"
            ]
          },
          "total_files": {
            "type": "number",
            "description": "Number of files the run processes"
          },
          "processed": {
            "type": "number",
            "description": "Records read across every file so far"
          },
          "created": {
            "type": "number",
            "description": "Users created across every file"
          },
          "failed": {
            "type": "number",
            "description": "Records that failed validation or creation across every file"
          },
          "started_at": {
            "format": "date-time",
            "type": "string",
            "description": "When the run was created"
          },
          "completed_at": {
            "format": "date-time",
            "type": "string",
            "description": "When the run ended. Absent while the run is still working."
          },
          "files": {
            "description": "Progress of each file of the run",
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ApiUserMigrationRunFile"
            }
          }
        },
        "required": [
          "run_id",
          "status",
          "mode",
          "total_files",
          "processed",
          "created",
          "failed",
          "started_at",
          "files"
        ]
      },
      "ApiCancelledUserMigrationRun": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "description": "Identifier of the cancelled run"
          },
          "status": {
            "type": "string",
            "description": "Status of the run after the cancel",
            "enum": [
              "running",
              "completed",
              "failed",
              "cancelled"
            ]
          }
        },
        "required": [
          "run_id",
          "status"
        ]
      },
      "ApiUserMigrationUploadUrl": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "The file name this presigned upload URL was generated for"
          },
          "url": {
            "type": "string",
            "description": "The storage endpoint where the multipart/form-data POST request must be sent"
          },
          "fields": {
            "type": "object",
            "description": "Required form fields to include in the upload payload"
          },
          "expires_at": {
            "type": "string",
            "description": "Timestamp when the upload URL expires and the storage provider will reject it"
          }
        },
        "required": [
          "name",
          "url",
          "fields",
          "expires_at"
        ]
      },
      "ApiUserMigrationFile": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the uploaded file"
          },
          "size": {
            "type": "number",
            "description": "Size of the file in bytes"
          }
        },
        "required": [
          "name",
          "size"
        ]
      },
      "ApiUserMigrationRunFile": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Name of the uploaded file"
          },
          "status": {
            "type": "string",
            "description": "Current status of this file",
            "enum": [
              "pending",
              "running",
              "completed",
              "failed"
            ]
          },
          "processed": {
            "type": "number",
            "description": "Records read from this file so far"
          },
          "created": {
            "type": "number",
            "description": "Users created from this file"
          },
          "failed": {
            "type": "number",
            "description": "Records of this file that failed validation or creation"
          },
          "outcome_url": {
            "type": "string",
            "description": "Time limited link to download the report of this file. Present once the file has completed."
          }
        },
        "required": [
          "name",
          "status",
          "processed",
          "created",
          "failed"
        ]
      }
    },
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "type": "http"
      },
      "UserAccessToken": {
        "type": "http",
        "description": "A token returned upon end-user authentication, which provides access to resources and data for the user and app for which it was generated",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      },
      "AdminAccessToken": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oidc/token",
            "scopes": {}
          }
        },
        "description": "A token generated by a management application using the [token endpoint](/openapi/token.openapi/other/getaccesstoken). It provides access to all resources for the tenant and its apps"
      },
      "ClientAccessToken": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oidc/token",
            "scopes": {}
          }
        },
        "description": "A token generated by an end-user application using the [token endpoint](/openapi/token.openapi/other/getaccesstoken). It provides access to resources and data on the tenant level or associated with the specific application (but not other apps in the tenant)"
      },
      "OrgAdminAccessToken": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "/oidc/token",
            "scopes": {}
          }
        },
        "description": "A token returned upon B2B authentication for a user that has the organizationAdmin or organizationCreator role."
      }
    }
  }
}