{
  "openapi": "3.0.0",
  "info": {
    "title": "2belive - External API",
    "version": "1.0.0"
  },
  "servers": [
    {
      "url": "https://api-stage.2belive.2belive.net/",
      "description": "Stage"
    },
    {
      "url": "https://api-prod-2belive.2belive.net/",
      "description": "Production"
    }
  ],
  "paths": {
    "/api/new_user": {
      "post": {
        "tags": [
          "external_api"
        ],
        "summary": "new_user",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "example": {
                  "email": "newuser_2023@gmail.com",
                  "role_name": "student",
                  "group_permission_ids": [],
                  "create_account": true
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "accessToken",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "description": "accessToken generated from our backoffice. Required permissions: create account"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/new_user_or_signin": {
      "post": {
        "tags": [
          "external_api"
        ],
        "summary": "new_user_or_sign_in",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "properties": {
                  "email": {
                    "description": "E-mail for the account being created",
                    "type": "string"
                  },
                  "role_name": {
                    "description": "Role for the account. Possible values are student, admin or teacher",
                    "type": "string"
                  },
                  "group_permission_ids": {
                    "description": "Groups the account will be added to. Array of integer ids. If none is provided, account is still being added to the default (free) group",
                    "type": "array",
                    "items": {
                      "type": "integer"
                    },
                    "example": [
                      1,
                      2,
                      3
                    ]
                  }
                },
                "type": "object",
                "example": {
                  "email": "newuser_2025abc@gmail.com",
                  "role_name": "student",
                  "group_permission_ids": []
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "accessToken",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "example": "{{ACCESSTOKEN}}"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "type": "object",
                      "description": "Account information for the provided email. Either a new account is created or the existing account is returned case the email is a match."
                    },
                    "magic_link": {
                      "type": "string",
                      "description": "Magic link for the account. Used as a link or redirection, it will take the browser to 2belive dashboard page, logged in as the given user"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/api/create_purchase": {
      "post": {
        "tags": [
          "external_api"
        ],
        "summary": "create_purchase",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "example": {
                  "type": "catalog",
                  "item_id": 2629,
                  "price": 123,
                  "user_id": 23956,
                  "external_id": "my-transaction_token",
                  "metadata": [
                    {
                      "transaction": 123,
                      "gateway": "pagarme"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "accessToken",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "example": "{{ACCESSTOKEN}}"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    },
    "/api/create_userpurchase": {
      "post": {
        "tags": [
          "external_api"
        ],
        "summary": "create_userpurchase",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "example": {
                  "items": [
                    {
                      "id": 6,
                      "type": "course",
                      "price": 1234
                    },
                    {
                      "id": 5,
                      "type": "course",
                      "price": 1234
                    }
                  ],
                  "email": "gandrade@2mundos.net",
                  "external_id": "my-transaction_token",
                  "metadata": [
                    {
                      "transaction": 123,
                      "gateway": "stripe"
                    }
                  ]
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "accessToken",
            "in": "header",
            "schema": {
              "type": "string"
            },
            "example": "{{ACCESSTOKEN}}"
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {}
            }
          }
        }
      }
    }
  },
  "components": {}
}