{
  "openapi": "3.1.0",
  "info": {
    "title": "IAasks Mission API",
    "version": "0.3.0",
    "description": "Submit human-reviewed requests for real-world actions."
  },
  "servers": [
    {
      "url": "https://iaasks.com"
    }
  ],
  "paths": {
    "/api/capabilities": {
      "get": {
        "operationId": "getCapabilities",
        "summary": "Discover IAasks capabilities",
        "responses": {
          "200": {
            "description": "Capability catalog"
          }
        }
      }
    },
    "/api/payments": {
      "get": {
        "operationId": "getPaymentMethods",
        "summary": "Discover the payment methods accepted by IAasks",
        "description": "Returns payment instructions for an approved mission. Creating a mission never triggers payment.",
        "responses": {
          "200": {
            "description": "Payment methods and safety instructions",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "payment_at_submission": {"type": "boolean", "const": false},
                    "instructions": {"type": "string"},
                    "methods": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "id": {"type": "string"},
                          "asset": {"type": "string"},
                          "network": {"type": "string"},
                          "address": {"type": "string"},
                          "payment_uri": {"type": "string"},
                          "payment_url": {"type": "string", "format": "uri"},
                          "provider": {"type": "string"},
                          "merchant": {"type": "string"},
                          "currency": {"type": "string"},
                          "amount_entered_by_payer": {"type": "boolean"},
                          "request_contact": {"type": "string"},
                          "payment_page": {"type": "string", "format": "uri"},
                          "reference_required": {"type": "boolean"},
                          "warnings": {"type": "array", "items": {"type": "string"}}
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/missions": {
      "post": {
        "operationId": "createMission",
        "summary": "Create a mission request",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "requester_name",
                  "email",
                  "mission_type",
                  "description"
                ],
                "properties": {
                  "requester_name": {
                    "type": "string",
                    "maxLength": 160
                  },
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 254
                  },
                  "mission_type": {
                    "type": "string",
                    "enum": [
                      "field_verification",
                      "human_call",
                      "app_testing",
                      "real_world_data",
                      "other"
                    ]
                  },
                  "description": {
                    "type": "string",
                    "minLength": 20,
                    "maxLength": 4000
                  },
                  "location": {
                    "type": "string",
                    "maxLength": 300
                  },
                  "budget": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "deadline": {
                    "type": "string",
                    "maxLength": 120
                  },
                  "source": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Mission request created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "tracking_token",
                    "tracking_url",
                    "status_endpoint"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "tracking_token": {
                      "type": "string"
                    },
                    "tracking_url": {
                      "type": "string"
                    },
                    "status_endpoint": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "next_step": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request"
          },
          "413": {
            "description": "Payload too large"
          },
          "415": {
            "description": "JSON required"
          },
          "503": {
            "description": "Temporarily unavailable"
          },
          "200": {
            "description": "Existing mission recovered; no duplicate created",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "id",
                    "status",
                    "tracking_token",
                    "tracking_url",
                    "status_endpoint"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "tracking_token": {
                      "type": "string"
                    },
                    "tracking_url": {
                      "type": "string"
                    },
                    "status_endpoint": {
                      "type": "string"
                    },
                    "created_at": {
                      "type": "string"
                    },
                    "next_step": {
                      "type": "string"
                    },
                    "message": {
                      "type": "string"
                    },
                    "replayed": {
                      "type": "boolean",
                      "const": true
                    }
                  }
                }
              }
            }
          },
          "409": {
            "description": "The idempotency key is already associated with different content"
          }
        },
        "parameters": [
          {
            "name": "Idempotency-Key",
            "in": "header",
            "required": false,
            "description": "Cryptographically random UUID v4, generated once per new mission. Keep private. Reuse with the same normalized payload to recover the receipt without a duplicate while the mission is retained. Use a new key for a different mission.",
            "schema": {
              "type": "string",
              "format": "uuid",
              "pattern": "^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-4[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$"
            }
          }
        ]
      }
    },
    "/api/missions/{id}": {
      "get": {
        "operationId": "getMissionStatus",
        "summary": "Read mission status with its private token",
        "security": [
          {
            "trackingToken": []
          }
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Status and human-authored public update",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "status": {
                      "type": "string"
                    },
                    "public_update": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "created_at": {
                      "type": "integer",
                      "description": "Unix milliseconds"
                    },
                    "updated_at": {
                      "type": [
                        "integer",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing token"
          },
          "404": {
            "description": "Unknown mission or wrong token"
          },
          "503": {
            "description": "Temporarily unavailable"
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "trackingToken": {
        "type": "http",
        "scheme": "bearer",
        "description": "Private tracking token returned once at creation."
      }
    }
  }
}
