{
  "openapi": "3.1.0",
  "info": {
    "title": "Backapp API",
    "version": "2.0.0",
    "description": "Initial reference for the Backapp image integration. Source baseline: owlly_api main at 21e55f3. Verify environment and request costs before running examples."
  },
  "servers": [
    {
      "url": "https://api.backapp.dev"
    }
  ],
  "paths": {
    "/v2/auth/device": {
      "post": {
        "operationId": "registerDevice",
        "summary": "Register a device",
        "security": [
          {
            "AppKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AppVersion"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "device_id": {
                    "type": "string",
                    "maxLength": 128,
                    "minLength": 1
                  }
                },
                "required": [
                  "device_id"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "is_new": {
                      "type": "boolean"
                    },
                    "access_token": {
                      "type": "string"
                    },
                    "refresh_token": {
                      "type": "string"
                    },
                    "subscription": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  },
                  "required": [
                    "user_id",
                    "is_new",
                    "access_token",
                    "refresh_token",
                    "subscription"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing app version header or invalid request fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "App credentials or user token rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v2/auth/refresh": {
      "post": {
        "operationId": "refreshSession",
        "summary": "Refresh a session",
        "security": [
          {
            "AppKey": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AppVersion"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "refresh_token": {
                    "type": "string"
                  }
                },
                "required": [
                  "refresh_token"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "refresh_token": {
                      "type": "string"
                    },
                    "subscription": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  },
                  "required": [
                    "access_token",
                    "refresh_token",
                    "subscription"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing app version header or invalid request fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "App credentials or user token rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/v2/me": {
      "get": {
        "operationId": "getCurrentUser",
        "summary": "Get the current user",
        "security": [
          {
            "AppKey": [],
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AppVersion"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user_id": {
                      "type": "string",
                      "format": "uuid"
                    },
                    "subscription": {
                      "$ref": "#/components/schemas/Subscription"
                    }
                  },
                  "required": [
                    "user_id",
                    "subscription"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "App credentials or user token rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing app version header."
          }
        }
      }
    },
    "/v2/image_effects": {
      "get": {
        "operationId": "listImageEffects",
        "summary": "List image effects",
        "security": [
          {
            "AppKey": [],
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AppVersion"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "categories": {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "properties": {
                          "title": {
                            "type": "string"
                          },
                          "effects": {
                            "type": "array",
                            "items": {
                              "type": "object",
                              "properties": {
                                "id": {
                                  "type": "integer"
                                },
                                "title": {
                                  "type": "string"
                                },
                                "image": {
                                  "type": [
                                    "string",
                                    "null"
                                  ]
                                }
                              },
                              "required": [
                                "id",
                                "title",
                                "image"
                              ]
                            }
                          }
                        },
                        "required": [
                          "title",
                          "effects"
                        ]
                      }
                    }
                  },
                  "required": [
                    "categories"
                  ]
                }
              }
            }
          },
          "401": {
            "description": "App credentials or user token rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "400": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            },
            "description": "Missing app version header."
          }
        }
      }
    },
    "/v2/image_effects/apply": {
      "post": {
        "operationId": "applyImageEffect",
        "summary": "Apply an image effect",
        "security": [
          {
            "AppKey": [],
            "Bearer": []
          }
        ],
        "parameters": [
          {
            "$ref": "#/components/parameters/AppVersion"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "effect_id",
                  "image"
                ],
                "properties": {
                  "effect_id": {
                    "type": "integer"
                  },
                  "image": {
                    "type": "string",
                    "format": "binary"
                  },
                  "prompt": {
                    "type": "string",
                    "description": "Missing or blank uses the configured effect prompt."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "image_url": {
                      "type": "string",
                      "format": "uri"
                    }
                  },
                  "required": [
                    "image_url"
                  ]
                }
              }
            }
          },
          "400": {
            "description": "Missing app version header or invalid request fields.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "401": {
            "description": "App credentials or user token rejected",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "503": {
            "description": "The effect could not be applied (effect_failed).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "AppKey": {
        "type": "apiKey",
        "in": "header",
        "name": "X-App-Key",
        "description": "Public application identifier."
      },
      "Bearer": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT"
      }
    },
    "parameters": {
      "AppVersion": {
        "name": "X-App-Version",
        "in": "header",
        "required": true,
        "schema": {
          "type": "string",
          "minLength": 1
        },
        "description": "Version of the client application."
      }
    },
    "schemas": {
      "Subscription": {
        "type": "object",
        "properties": {
          "is_active": {
            "type": "boolean"
          },
          "is_trial": {
            "type": "boolean"
          },
          "product_id": {
            "type": "string"
          },
          "expires_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "will_renew": {
            "type": [
              "boolean",
              "null"
            ]
          }
        },
        "required": [
          "is_active",
          "is_trial",
          "product_id",
          "expires_at",
          "will_renew"
        ]
      },
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              },
              "fields": {
                "type": "object",
                "additionalProperties": true
              }
            }
          }
        },
        "required": [
          "error"
        ]
      }
    }
  }
}
