{
  "openapi": "3.0.3",
  "info": {
    "title": "Biky Identity API",
    "version": "1.0.0",
    "description": "Authentication for every Biky API: API keys, access tokens, users and team membership of your app."
  },
  "servers": [
    {
      "url": "https://identity.keybeapi.com",
      "description": "Production"
    }
  ],
  "tags": [
    {
      "name": "Authentication",
      "description": "API keys, access tokens and how to verify them."
    },
    {
      "name": "API keys",
      "description": "Machine credentials of an app, owned by one of its admins."
    },
    {
      "name": "Users",
      "description": "The current user and the users of your app."
    },
    {
      "name": "Team",
      "description": "Who belongs to your app and with which role."
    }
  ],
  "paths": {
    "/v1/oauth/token": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Exchange an API key for an access token",
        "description": "OAuth 2.0 `client_credentials` grant: send your API key as `client_secret` (JSON or form-encoded) and get a short-lived JWT (`access_token`, `expires_in`). Useful for high-volume integrations: you can verify the token locally with the public keys from `/.well-known/jwks.json` instead of sending the API key on every call. Errors follow RFC 6749 (`invalid_client`, `unsupported_grant_type`).",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_secret"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "client_credentials"
                    ]
                  },
                  "client_secret": {
                    "type": "string",
                    "description": "Your API key."
                  }
                }
              },
              "example": {
                "grant_type": "client_credentials",
                "client_secret": "sk-3f9a1c8b2e4dXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
              }
            },
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type",
                  "client_secret"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "client_credentials"
                    ]
                  },
                  "client_secret": {
                    "type": "string",
                    "description": "Your API key."
                  }
                }
              },
              "example": {
                "grant_type": "client_credentials",
                "client_secret": "sk-3f9a1c8b2e4dXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Token issued",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string",
                      "enum": [
                        "Bearer"
                      ]
                    },
                    "expires_in": {
                      "type": "integer"
                    }
                  }
                },
                "example": {
                  "access_token": "eyJhbGciOiJFUzI1NiIs…",
                  "token_type": "Bearer",
                  "expires_in": 600
                }
              }
            }
          },
          "400": {
            "description": "Malformed request or unsupported grant",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "unsupported_grant_type"
                }
              }
            }
          },
          "401": {
            "description": "Unknown, expired or revoked API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                },
                "example": {
                  "error": "invalid_client"
                }
              }
            }
          }
        },
        "operationId": "exchangeApiKeyForToken",
        "security": []
      }
    },
    "/v1/auth/introspect": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Inspect a credential",
        "description": "Tells you who a credential is: send an API key or an access token as `Authorization: Bearer` and get the user, role and app it resolves to. Pass `x-app-uuid` to resolve the membership in a specific app. Never fails: anything invalid, expired or revoked returns `{ \"active\": false }`.",
        "parameters": [
          {
            "name": "x-app-uuid",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "`appUUID` to resolve the membership in. Without it, the app of the API key or of the token.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "responses": {
          "200": {
            "description": "Principal",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Principal"
                },
                "examples": {
                  "apiKey": {
                    "summary": "A valid API key",
                    "value": {
                      "active": true,
                      "credentialType": "apikey",
                      "user": {
                        "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                        "userId": "u_8f2k1m",
                        "email": "laura@example.com",
                        "name": "Laura",
                        "lastName": "Gómez"
                      },
                      "app": "app_7f3k2m9x1q",
                      "role": "admin",
                      "isMember": true,
                      "expiresAt": "2027-06-30T23:59:59.000Z"
                    }
                  },
                  "invalid": {
                    "summary": "Invalid, expired or revoked",
                    "value": {
                      "active": false
                    }
                  }
                }
              }
            }
          }
        },
        "operationId": "introspectCredential"
      }
    },
    "/v1/auth/login": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Log in with email and password",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/LoginRequest"
              },
              "example": {
                "email": "laura@example.com",
                "password": "S3gura-2026!",
                "appUUID": "app_7f3k2m9x1q"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResult"
                },
                "example": {
                  "user": {
                    "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                    "userId": "u_8f2k1m",
                    "email": "laura@example.com",
                    "name": "Laura",
                    "lastName": "Gómez",
                    "photo": "https://cdn.example.com/avatars/laura.jpg",
                    "isSuperAdmin": false,
                    "isBkManager": false
                  },
                  "tokens": {
                    "accessToken": "eyJhbGciOiJFUzI1NiIs…",
                    "refreshToken": "6a7b8c9d-0e1f-4a2b-9c3d-4e5f6a7b8c9d.q9Zk…",
                    "tokenType": "Bearer",
                    "expiresAt": "2026-11-13T16:00:00.000Z",
                    "refreshExpiresAt": "2026-12-13T15:00:00.000Z",
                    "tokenUuid": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Rate limited",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "login",
        "description": "Returns an access token and a refresh token for a Biky user. Use it only when your integration acts on behalf of a person; for server-to-server integrations use an API key. Repeated failures are rate limited (`429`).",
        "security": []
      }
    },
    "/v1/auth/refresh": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Refresh an access token",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/RefreshRequest"
              },
              "example": {
                "refreshToken": "6a7b8c9d-0e1f-4a2b-9c3d-4e5f6a7b8c9d.q9Zk…"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthResult"
                },
                "example": {
                  "user": {
                    "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                    "userId": "u_8f2k1m",
                    "email": "laura@example.com",
                    "name": "Laura",
                    "lastName": "Gómez",
                    "photo": "https://cdn.example.com/avatars/laura.jpg",
                    "isSuperAdmin": false,
                    "isBkManager": false
                  },
                  "tokens": {
                    "accessToken": "eyJhbGciOiJFUzI1NiIs…",
                    "refreshToken": "6a7b8c9d-0e1f-4a2b-9c3d-4e5f6a7b8c9d.q9Zk…",
                    "tokenType": "Bearer",
                    "expiresAt": "2026-11-13T16:00:00.000Z",
                    "refreshExpiresAt": "2026-12-13T15:00:00.000Z",
                    "tokenUuid": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "refreshToken",
        "description": "Exchanges a refresh token for a new token pair. The old refresh token stops working.",
        "security": []
      }
    },
    "/v1/auth/validate": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Validate an access token",
        "description": "Checks an access token issued by Identity. For high volume, verify the signature locally with the public keys from `/.well-known/jwks.json`.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ValidateRequest"
              },
              "example": {
                "token": "eyJhbGciOiJFUzI1NiIs…"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ValidateResponse"
                },
                "example": {
                  "valid": true,
                  "claims": {
                    "iss": "https://identity.keybeapi.com",
                    "iat": 1794583200,
                    "exp": 1794583800,
                    "token": "3e4f5a6b-7c8d-4e9f-a0b1-c2d3e4f5a6b7",
                    "id": "u_8f2k1m",
                    "sub": "u_8f2k1m",
                    "email": "laura@example.com",
                    "isSuperAdmin": false,
                    "isBkManager": false,
                    "type": "access",
                    "app": "app_7f3k2m9x1q",
                    "grant": "client_credentials"
                  }
                }
              }
            }
          }
        },
        "operationId": "validateToken",
        "security": []
      }
    },
    "/v1/auth/logout": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Log out",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "logout",
        "description": "Revokes the session of the token making the call."
      }
    },
    "/v1/auth/logout-all": {
      "post": {
        "tags": [
          "Authentication"
        ],
        "summary": "Log out everywhere",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "logoutAll",
        "description": "Revokes every session of the current user."
      }
    },
    "/.well-known/jwks.json": {
      "get": {
        "tags": [
          "Authentication"
        ],
        "summary": "Get the public signing keys",
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Jwks"
                },
                "example": {
                  "keys": [
                    {
                      "kty": "EC",
                      "crv": "P-256",
                      "x": "f83OJ3D2xF1Bg8vub9tLe1gHMzV76e8Tus9uPHvRVEU",
                      "y": "x_FEzRu9m36HLN_tue659LNpXW6pCyStikYjKIWI5a0",
                      "kid": "5d1e2f3a-4b5c-4d6e-8f70-1a2b3c4d5e6f",
                      "alg": "ES256",
                      "use": "sig"
                    }
                  ]
                }
              }
            }
          }
        },
        "operationId": "getJwks",
        "description": "JSON Web Key Set to verify, locally, the signature of the access tokens Identity issues.",
        "security": []
      }
    },
    "/v1/users/me": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get the current user",
        "description": "The user behind the credential, with their app memberships.",
        "responses": {
          "200": {
            "description": "User",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                },
                "example": {
                  "user": {
                    "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                    "userId": "u_8f2k1m",
                    "name": "Laura",
                    "lastName": "Gómez",
                    "email": "laura@example.com",
                    "phone": "3001234567",
                    "countryCode": 57,
                    "country": "Colombia",
                    "birthday": "1990-05-21",
                    "identification": {
                      "type": "CC",
                      "number": "1020304050"
                    },
                    "address": {
                      "country": "Colombia",
                      "province": "Antioquia",
                      "city": "Medellín",
                      "zone": "El Poblado"
                    },
                    "photo": "https://cdn.example.com/avatars/laura.jpg",
                    "termsAccepted": true,
                    "lastAccessAt": "2026-11-13T14:58:21.000Z"
                  },
                  "memberships": [
                    {
                      "appUUID": "app_7f3k2m9x1q",
                      "role": "admin",
                      "agentType": null,
                      "isOwner": true,
                      "inactive": false,
                      "inactiveAt": null,
                      "inactiveReason": null,
                      "isViewAllSpaceChat": true,
                      "isVisible": true,
                      "inheritedFromAppUUID": null,
                      "position": "salesManager",
                      "externalId": "EMP-0102",
                      "termsAcceptedAt": "2026-03-02T14:10:00.000Z"
                    }
                  ],
                  "preferences": {
                    "lang": "es"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getMe"
      },
      "patch": {
        "tags": [
          "Users"
        ],
        "summary": "Update the current user profile",
        "description": "Send only the fields to change: profile fields, `address{country, province, city, zone}`, `identification{type, number}`, `preferences` (merged by key, `null` deletes a key) and `termsAccepted`. `null` clears a field, unknown keys answer 400, and the response is the full user, as `GET /v1/users/me` returns it.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MePatchRequest"
              },
              "example": {
                "phone": "3001234567",
                "address": {
                  "city": "Medellín",
                  "zone": "El Poblado"
                },
                "preferences": {
                  "lang": "es"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated user",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MeResponse"
                },
                "example": {
                  "user": {
                    "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                    "userId": "u_8f2k1m",
                    "name": "Laura",
                    "lastName": "Gómez",
                    "email": "laura@example.com",
                    "phone": "3001234567",
                    "countryCode": 57,
                    "country": "Colombia",
                    "birthday": "1990-05-21",
                    "identification": {
                      "type": "CC",
                      "number": "1020304050"
                    },
                    "address": {
                      "country": "Colombia",
                      "province": "Antioquia",
                      "city": "Medellín",
                      "zone": "El Poblado"
                    },
                    "photo": "https://cdn.example.com/avatars/laura.jpg",
                    "termsAccepted": true,
                    "lastAccessAt": "2026-11-13T14:58:21.000Z"
                  },
                  "memberships": [
                    {
                      "appUUID": "app_7f3k2m9x1q",
                      "role": "admin",
                      "agentType": null,
                      "isOwner": true,
                      "inactive": false,
                      "inactiveAt": null,
                      "inactiveReason": null,
                      "isViewAllSpaceChat": true,
                      "isVisible": true,
                      "inheritedFromAppUUID": null,
                      "position": "salesManager",
                      "externalId": "EMP-0102",
                      "termsAcceptedAt": "2026-03-02T14:10:00.000Z"
                    }
                  ],
                  "preferences": {
                    "lang": "es"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Email already in use",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "updateMe"
      }
    },
    "/v1/users/{userId}": {
      "get": {
        "tags": [
          "Users"
        ],
        "summary": "Get a user",
        "description": "Looks up a user by their business id. Requires the `admin` or `coordinator` role.",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "User business id.",
            "example": "u_8f2k1m"
          }
        ],
        "responses": {
          "200": {
            "description": "User",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/UserSummary"
                    }
                  }
                },
                "example": {
                  "user": {
                    "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                    "userId": "u_8f2k1m",
                    "email": "laura@example.com",
                    "name": "Laura",
                    "lastName": "Gómez",
                    "photo": "https://cdn.example.com/avatars/laura.jpg"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getUser"
      },
      "patch": {
        "tags": [
          "Users"
        ],
        "summary": "Update a user profile",
        "description": "Updates the profile of a member of your app. Requires the `admin` or `coordinator` role. Only the user can change their own email, with `PATCH /v1/users/me`.",
        "parameters": [
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "User business id.",
            "example": "u_5t7y9u1i"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ProfilePatchRequest"
              },
              "example": {
                "phone": "3001112233",
                "address_city": "Medellín",
                "lang": "es"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated user",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "user": {
                      "$ref": "#/components/schemas/UserProfile"
                    }
                  }
                },
                "example": {
                  "user": {
                    "uuid": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "userId": "u_5t7y9u1i",
                    "email": "andres@example.com",
                    "name": "Andrés",
                    "lastName": "Pérez",
                    "phone": "3001112233",
                    "photo": null,
                    "country": "Colombia",
                    "countryCode": 57,
                    "identification_type": null,
                    "identification": null,
                    "birthday": null,
                    "address_country": "Colombia",
                    "address_province": "Antioquia",
                    "address_city": "Medellín",
                    "address_zone": null,
                    "lang": "es"
                  }
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "updateUser"
      }
    },
    "/v1/apps/{appUUID}/apikeys": {
      "get": {
        "tags": [
          "API keys"
        ],
        "summary": "List the API keys of an app",
        "description": "Requires the `admin` role and a user session: an API key (or a token exchanged from one) gets `403`. Hashed keys are listed by their public prefix only.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "responses": {
          "200": {
            "description": "API keys",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apikeys": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ApiKey"
                      }
                    }
                  }
                },
                "example": {
                  "apikeys": [
                    {
                      "id": "k3c1e5b7a-9d2f-4e8a-b6c4-1f0a2d3e4b5c",
                      "key": "sk-3f9a1c8b2e4d",
                      "app": "app_7f3k2m9x1q",
                      "generic": false,
                      "createdAt": "2026-11-13T15:00:00.000Z",
                      "expiredAt": "2027-11-13T15:00:00.000Z",
                      "owner": {
                        "userId": "u_8f2k1m",
                        "name": "Laura",
                        "lastName": "Gómez",
                        "photo": "https://cdn.example.com/avatars/laura.jpg"
                      }
                    }
                  ]
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "listApiKeys"
      },
      "post": {
        "tags": [
          "API keys"
        ],
        "summary": "Create an API key",
        "description": "Creates a key owned by the caller, who must be an `admin` of the app with a user session (not an API key). The full key is returned **once**, in this response: store it right away. `expiredAt` is optional: without it the key expires one year after it is created; if you send it, it must be in the future and at most 5 years ahead.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CreateApiKeyRequest"
              },
              "example": {
                "expiredAt": "2027-11-13T00:00:00Z"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Created key",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "apikey": {
                      "$ref": "#/components/schemas/ApiKey"
                    }
                  }
                },
                "example": {
                  "apikey": {
                    "id": "k3c1e5b7a-9d2f-4e8a-b6c4-1f0a2d3e4b5c",
                    "key": "sk-3f9a1c8b2e4dXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
                    "app": "app_7f3k2m9x1q",
                    "generic": false,
                    "createdAt": "2026-11-13T15:00:00.000Z",
                    "expiredAt": "2027-11-13T00:00:00.000Z",
                    "owner": {
                      "userId": "u_8f2k1m",
                      "name": "Laura",
                      "lastName": "Gómez",
                      "photo": "https://cdn.example.com/avatars/laura.jpg"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "createApiKey"
      }
    },
    "/v1/apps/{appUUID}/apikeys/{id}": {
      "delete": {
        "tags": [
          "API keys"
        ],
        "summary": "Revoke an API key",
        "description": "In most modules the key stops working within a minute; in Smart Chat and Outbound it can take up to 5 minutes, because they remember valid keys for that long. Requires the `admin` role and a user session.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "API key `id`, as `GET /v1/apps/{appUUID}/apikeys` lists it.",
            "example": "k3c1e5b7a-9d2f-4e8a-b6c4-1f0a2d3e4b5c"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "revokeApiKey"
      }
    },
    "/v1/apps/{appUUID}/members": {
      "get": {
        "tags": [
          "Team"
        ],
        "summary": "List the members of an app",
        "description": "Any member of the app can call it. Without `limit` it returns every member. Deactivated members (`inactive`) and members inherited from a parent app (`includeHidden`) are listed only for admins.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "role",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "agent,coordinator",
            "description": "Only members with these roles, comma-separated."
          },
          {
            "name": "search",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "gómez",
            "description": "Text contained in the name, last name, email or phone."
          },
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 1000
            },
            "example": 50,
            "description": "Members per page, 1–1000. Without it, the response has every member."
          },
          {
            "name": "offset",
            "in": "query",
            "required": false,
            "schema": {
              "type": "integer",
              "minimum": 0,
              "default": 0
            },
            "example": 0,
            "description": "How many members to skip, counting from 0. Only applies with `limit`."
          },
          {
            "name": "inactive",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": false,
            "description": "`true` lists only the deactivated members. Admins only: for anyone else the list comes back empty."
          },
          {
            "name": "includeHidden",
            "in": "query",
            "required": false,
            "schema": {
              "type": "boolean",
              "default": false
            },
            "example": false,
            "description": "`true` also lists the members inherited from a parent app. Admins only."
          }
        ],
        "responses": {
          "200": {
            "description": "Members",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "members": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Member"
                      }
                    },
                    "page": {
                      "type": "object",
                      "properties": {
                        "offset": {
                          "type": "integer"
                        },
                        "limit": {
                          "type": "integer",
                          "nullable": true,
                          "description": "`null` when you did not send `limit`."
                        },
                        "total": {
                          "type": "integer",
                          "description": "Members that match the filters, across all pages."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "members": [
                    {
                      "userId": "u_8f2k1m",
                      "userBusinessId": "u_8f2k1m",
                      "uuid": "0b6c1d2e-3f40-4a51-8b62-7c83d94ea0f1",
                      "name": "Laura",
                      "lastName": "Gómez",
                      "email": "laura@example.com",
                      "phone": "3001234567",
                      "countryCode": 57,
                      "photo": "https://cdn.example.com/avatars/laura.jpg",
                      "lastAccessAt": "2026-11-13T14:58:21.000Z",
                      "role": "admin",
                      "agentType": null,
                      "isOwner": true,
                      "inactive": false,
                      "inactiveAt": null,
                      "inactiveReason": null,
                      "isViewAllSpaceChat": true,
                      "isVisible": true,
                      "inheritedFromAppUUID": null,
                      "position": "salesManager",
                      "externalId": "EMP-0102",
                      "termsAcceptedAt": "2026-03-02T14:10:00.000Z"
                    },
                    {
                      "userId": "u_5t7y9u1i",
                      "userBusinessId": "u_5t7y9u1i",
                      "uuid": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                      "name": "Andrés",
                      "lastName": "Pérez",
                      "email": "andres@example.com",
                      "phone": "3001112233",
                      "countryCode": 57,
                      "photo": null,
                      "lastAccessAt": "2026-11-12T21:47:10.000Z",
                      "role": "agent",
                      "agentType": "floor",
                      "isOwner": false,
                      "inactive": false,
                      "inactiveAt": null,
                      "inactiveReason": null,
                      "isViewAllSpaceChat": false,
                      "isVisible": true,
                      "inheritedFromAppUUID": null,
                      "position": "salesAdvisor",
                      "externalId": "EMP-0231",
                      "termsAcceptedAt": "2026-05-04T13:22:00.000Z"
                    }
                  ],
                  "page": {
                    "offset": 0,
                    "limit": 50,
                    "total": 2
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "listMembers"
      },
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "Add an existing user to the app",
        "description": "Adds a user that already has a Biky account, by `userId` or `email`, with a role. To bring someone new, use `inviteMember`. Requires the `admin` role, and only the owner of the app can add an admin.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AddMemberRequest"
              },
              "example": {
                "email": "andres@example.com",
                "role": "agent",
                "agentType": "digital"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Member added",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "member": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "integer",
                          "description": "Numeric user id."
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "invited",
                            "partner",
                            "coordinator",
                            "agent",
                            "custom",
                            "trainer"
                          ]
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "digital",
                            "floor"
                          ],
                          "nullable": true
                        },
                        "reactivated": {
                          "type": "boolean",
                          "description": "`true` when the user had been removed from the app and got their access back."
                        },
                        "promoted": {
                          "type": "boolean",
                          "description": "`true` when the user had access inherited from a parent app and now is a direct member."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "member": {
                    "userId": 51877,
                    "role": "agent",
                    "agentType": "digital",
                    "reactivated": false,
                    "promoted": false
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid role or missing identifier",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "User or app not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Already a member",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "addMember"
      }
    },
    "/v1/apps/{appUUID}/invitations": {
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "Invite someone to the team",
        "description": "New email: creates the account, the membership, and emails a single-use link (valid 7 days) to set the password. Existing account: only adds it to the app. Requires the `admin` role, and only the owner of the app can invite an admin.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "responses": {
          "201": {
            "description": "Invited or linked",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "member": {
                      "type": "object",
                      "properties": {
                        "status": {
                          "type": "string",
                          "enum": [
                            "invited",
                            "linked"
                          ],
                          "description": "`invited`: the account was created and the invitation went out. `linked`: the email already had an account, which was added to the app."
                        },
                        "userId": {
                          "type": "integer",
                          "description": "Numeric user id."
                        },
                        "uuid": {
                          "type": "string",
                          "description": "User UUID. It is the agent id in Smart Chat and Analytics."
                        },
                        "userBusinessId": {
                          "type": "string",
                          "description": "User business id."
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "invited",
                            "partner",
                            "coordinator",
                            "agent",
                            "custom",
                            "trainer"
                          ]
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "digital",
                            "floor"
                          ],
                          "nullable": true
                        },
                        "reactivated": {
                          "type": "boolean",
                          "description": "`true` when the user had been removed from the app and got their access back."
                        },
                        "promoted": {
                          "type": "boolean",
                          "description": "`true` when the user had access inherited from a parent app and now is a direct member."
                        },
                        "emailSent": {
                          "type": "boolean",
                          "description": "`true` when an invitation email went out. An existing account gets one only while it has not set its password."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "member": {
                    "status": "invited",
                    "userId": 51877,
                    "uuid": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "userBusinessId": "u_5t7y9u1i",
                    "role": "agent",
                    "agentType": "digital",
                    "reactivated": false,
                    "promoted": false,
                    "emailSent": true
                  }
                }
              }
            }
          },
          "400": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "inviteMember",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "email",
                  "name",
                  "role"
                ],
                "properties": {
                  "email": {
                    "type": "string",
                    "format": "email",
                    "maxLength": 150
                  },
                  "name": {
                    "type": "string",
                    "maxLength": 100,
                    "minLength": 1
                  },
                  "lastName": {
                    "type": "string",
                    "maxLength": 100,
                    "nullable": true
                  },
                  "phone": {
                    "type": "string",
                    "maxLength": 20,
                    "nullable": true
                  },
                  "countryCode": {
                    "type": "integer",
                    "nullable": true,
                    "description": "Phone country calling code, e.g. 57."
                  },
                  "role": {
                    "type": "string",
                    "enum": [
                      "admin",
                      "invited",
                      "partner",
                      "coordinator",
                      "agent",
                      "custom",
                      "trainer"
                    ],
                    "description": "Role of the member in the app (*Type* in the platform). The platform offers `admin`, `coordinator`, `agent` and `trainer`."
                  },
                  "agentType": {
                    "type": "string",
                    "enum": [
                      "digital",
                      "floor"
                    ],
                    "nullable": true,
                    "description": "Only for `agent`, in automotive apps: whether the person works over chat (`digital`) or in person at the dealership (`floor`). `null` on any other role, and read as `digital`."
                  },
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ],
                    "description": "Language of the invitation email. Defaults to `es`."
                  }
                }
              },
              "example": {
                "email": "andres@example.com",
                "name": "Andrés",
                "lastName": "Pérez",
                "phone": "3001112233",
                "countryCode": 57,
                "role": "agent",
                "agentType": "digital",
                "lang": "es"
              }
            }
          }
        }
      }
    },
    "/v1/apps/{appUUID}/invitations/{userId}/resend": {
      "post": {
        "tags": [
          "Team"
        ],
        "summary": "Resend an invitation",
        "description": "Requires the `admin` role.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "User business id.",
            "example": "u_5t7y9u1i"
          }
        ],
        "responses": {
          "200": {
            "description": "Sent",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "emailSent": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "emailSent": true
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "409": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "resendInvitation",
        "requestBody": {
          "required": false,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "lang": {
                    "type": "string",
                    "enum": [
                      "es",
                      "en"
                    ],
                    "description": "Language of the invitation email. Defaults to `es`."
                  }
                }
              },
              "example": {
                "lang": "es"
              }
            }
          }
        }
      }
    },
    "/v1/apps/{appUUID}/members/{userId}": {
      "get": {
        "tags": [
          "Team"
        ],
        "summary": "Get a member",
        "description": "Any member of the app can call it. Deactivated members and members inherited from a parent app are visible only to admins.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "User business id.",
            "example": "u_5t7y9u1i"
          }
        ],
        "responses": {
          "200": {
            "description": "Member",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "member": {
                      "$ref": "#/components/schemas/Member"
                    }
                  }
                },
                "example": {
                  "member": {
                    "userId": "u_5t7y9u1i",
                    "userBusinessId": "u_5t7y9u1i",
                    "uuid": "9f2c4a7e-1b3d-4e5f-8a6b-7c8d9e0f1a2b",
                    "name": "Andrés",
                    "lastName": "Pérez",
                    "email": "andres@example.com",
                    "phone": "3001112233",
                    "countryCode": 57,
                    "photo": null,
                    "lastAccessAt": "2026-11-12T21:47:10.000Z",
                    "role": "agent",
                    "agentType": "floor",
                    "isOwner": false,
                    "inactive": false,
                    "inactiveAt": null,
                    "inactiveReason": null,
                    "isViewAllSpaceChat": false,
                    "isVisible": true,
                    "inheritedFromAppUUID": null,
                    "position": "salesAdvisor",
                    "externalId": "EMP-0231",
                    "termsAcceptedAt": "2026-05-04T13:22:00.000Z"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "getMember"
      },
      "patch": {
        "tags": [
          "Team"
        ],
        "summary": "Update a member",
        "description": "Changes any of `role`, `agentType`, `inactive` (+ `inactiveReason`), `isViewAllSpaceChat`, `position` and `externalId`. The owner cannot be deactivated, and only the owner of the app can edit an admin or make someone an admin. Requires the `admin` role.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Numeric user id or user business id.",
            "example": "u_5t7y9u1i"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/MemberPatchRequest"
              },
              "example": {
                "role": "agent",
                "agentType": "floor",
                "position": "salesAdvisor",
                "externalId": "EMP-0231"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "member": {
                      "type": "object",
                      "properties": {
                        "userId": {
                          "type": "string",
                          "description": "The `userId` you sent in the path."
                        },
                        "role": {
                          "type": "string",
                          "enum": [
                            "admin",
                            "invited",
                            "partner",
                            "coordinator",
                            "agent",
                            "custom",
                            "trainer"
                          ]
                        },
                        "agentType": {
                          "type": "string",
                          "enum": [
                            "digital",
                            "floor"
                          ],
                          "nullable": true
                        },
                        "inactive": {
                          "type": "integer",
                          "enum": [
                            0,
                            1
                          ],
                          "description": "`1` when the member is deactivated."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "member": {
                    "userId": "u_5t7y9u1i",
                    "role": "agent",
                    "agentType": "floor",
                    "inactive": 0
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid role, or inherited membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "updateMember"
      },
      "delete": {
        "tags": [
          "Team"
        ],
        "summary": "Remove a member",
        "description": "Soft-removes the membership: adding the user again gives their access back. Requires the `admin` role, and only the owner of the app can remove an admin.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          },
          {
            "name": "userId",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Numeric user id or user business id.",
            "example": "u_5t7y9u1i"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "type": "boolean"
                    }
                  }
                },
                "example": {
                  "success": true
                }
              }
            }
          },
          "400": {
            "description": "Cannot remove the owner / inherited membership",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "removeMember"
      }
    },
    "/v1/apps/{appUUID}/owner": {
      "put": {
        "tags": [
          "Team"
        ],
        "summary": "Transfer the app ownership",
        "description": "Makes an admin of the app its owner. Only the current owner can do it.",
        "parameters": [
          {
            "name": "appUUID",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Your app UUID (shown in Settings → API keys). The credential must belong to a member of this app.",
            "example": "app_7f3k2m9x1q"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TransferOwnerRequest"
              },
              "example": {
                "userId": "u_5t7y9u1i"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Ownership transferred",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "owner": {
                      "type": "object",
                      "properties": {
                        "ownerUserId": {
                          "type": "integer",
                          "description": "Numeric id of the new owner."
                        }
                      }
                    }
                  }
                },
                "example": {
                  "owner": {
                    "ownerUserId": 51877
                  }
                }
              }
            }
          },
          "400": {
            "description": "The new owner must be an active admin of the app",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "403": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "404": {
            "description": "Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "operationId": "transferOwnership"
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "Your app's API key (Settings → API keys) or an Identity access token."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      },
      "Device": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string"
          },
          "os": {
            "type": "string"
          },
          "client": {
            "type": "string"
          }
        }
      },
      "LoginRequest": {
        "type": "object",
        "required": [
          "email",
          "password"
        ],
        "properties": {
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 150
          },
          "password": {
            "type": "string",
            "minLength": 1
          },
          "appUUID": {
            "type": "string",
            "description": "Scope the session to an app"
          },
          "deviceType": {
            "type": "string"
          },
          "device": {
            "$ref": "#/components/schemas/Device"
          }
        }
      },
      "PublicUser": {
        "type": "object",
        "properties": {
          "uuid": {
            "type": "string"
          },
          "userId": {
            "type": "string",
            "description": "Business id"
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "photo": {
            "type": "string",
            "nullable": true,
            "description": "Avatar URL"
          },
          "isSuperAdmin": {
            "type": "boolean"
          },
          "isBkManager": {
            "type": "boolean",
            "description": "Keybe staff with admin access to every app"
          }
        }
      },
      "IssuedTokens": {
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string",
            "description": "Access token (JWT)"
          },
          "refreshToken": {
            "type": "string",
            "description": "Opaque refresh token"
          },
          "tokenType": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "refreshExpiresAt": {
            "type": "string",
            "format": "date-time"
          },
          "tokenUuid": {
            "type": "string"
          }
        }
      },
      "AuthResult": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/PublicUser"
          },
          "tokens": {
            "$ref": "#/components/schemas/IssuedTokens"
          }
        }
      },
      "RefreshRequest": {
        "type": "object",
        "required": [
          "refreshToken"
        ],
        "properties": {
          "refreshToken": {
            "type": "string",
            "minLength": 1
          },
          "deviceType": {
            "type": "string"
          }
        }
      },
      "ValidateRequest": {
        "type": "object",
        "required": [
          "token"
        ],
        "properties": {
          "token": {
            "type": "string",
            "minLength": 1
          }
        }
      },
      "ValidateResponse": {
        "type": "object",
        "properties": {
          "valid": {
            "type": "boolean"
          },
          "claims": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "ProfilePatchRequest": {
        "type": "object",
        "description": "Partial update — send only the fields to change. `lang` sets the language of the emails Biky sends to the user.",
        "properties": {
          "name": {
            "type": "string",
            "maxLength": 100,
            "minLength": 1
          },
          "lastName": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "countryCode": {
            "type": "integer",
            "nullable": true,
            "description": "Phone country calling code, e.g. 57."
          },
          "identification_type": {
            "type": "string",
            "nullable": true,
            "maxLength": 30,
            "description": "Document type."
          },
          "identification": {
            "type": "string",
            "nullable": true,
            "maxLength": 50,
            "description": "Document number."
          },
          "photo": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "pattern": "^https://",
            "maxLength": 500,
            "description": "HTTPS URL of the profile photo."
          },
          "birthday": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "nullable": true,
            "description": "Date of birth, `YYYY-MM-DD`."
          },
          "address_country": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "address_province": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "address_city": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "address_zone": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "lang": {
            "type": "string",
            "maxLength": 10
          }
        },
        "minProperties": 1
      },
      "MePatchRequest": {
        "type": "object",
        "description": "Partial update of the current user: send at least one field. Unknown fields answer 400.",
        "additionalProperties": false,
        "minProperties": 1,
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 100
          },
          "lastName": {
            "type": "string",
            "nullable": true,
            "maxLength": 100
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 150
          },
          "phone": {
            "type": "string",
            "nullable": true,
            "maxLength": 20
          },
          "country": {
            "type": "string",
            "nullable": true,
            "maxLength": 60
          },
          "countryCode": {
            "type": "integer",
            "nullable": true,
            "description": "Phone country calling code, e.g. 57."
          },
          "photo": {
            "type": "string",
            "format": "uri",
            "pattern": "^https://",
            "maxLength": 500,
            "nullable": true,
            "description": "HTTPS URL of the profile photo."
          },
          "birthday": {
            "type": "string",
            "pattern": "^\\d{4}-\\d{2}-\\d{2}$",
            "nullable": true,
            "description": "Date of birth, `YYYY-MM-DD`."
          },
          "identification": {
            "type": "object",
            "additionalProperties": false,
            "description": "ID document.",
            "properties": {
              "type": {
                "type": "string",
                "nullable": true,
                "maxLength": 30,
                "description": "Document type."
              },
              "number": {
                "type": "string",
                "nullable": true,
                "maxLength": 50,
                "description": "Document number."
              }
            }
          },
          "address": {
            "type": "object",
            "additionalProperties": false,
            "properties": {
              "country": {
                "type": "string",
                "nullable": true,
                "maxLength": 60
              },
              "province": {
                "type": "string",
                "nullable": true,
                "maxLength": 60
              },
              "city": {
                "type": "string",
                "nullable": true,
                "maxLength": 60
              },
              "zone": {
                "type": "string",
                "nullable": true,
                "maxLength": 60
              }
            }
          },
          "preferences": {
            "type": "object",
            "maxProperties": 500,
            "additionalProperties": {},
            "description": "User settings as key-value pairs, merged by key: `null` deletes a key. At most 500 keys per request, each 1–100 characters long; each value, stored as text or JSON, at most 65,535 characters."
          },
          "termsAccepted": {
            "type": "boolean",
            "description": "`true` marks the terms and conditions as accepted; `false` unmarks them."
          }
        }
      },
      "Member": {
        "type": "object",
        "description": "A member of the app: their profile and their access to this app.",
        "properties": {
          "userId": {
            "type": "string",
            "description": "User business id."
          },
          "userBusinessId": {
            "type": "string",
            "deprecated": true,
            "description": "Same value as `userId`."
          },
          "uuid": {
            "type": "string",
            "description": "User UUID. It is the agent id in Smart Chat and Analytics."
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "countryCode": {
            "type": "integer",
            "nullable": true,
            "description": "Phone country calling code, e.g. 57."
          },
          "photo": {
            "type": "string",
            "nullable": true,
            "description": "Avatar URL"
          },
          "lastAccessAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "Last time the user logged in."
          },
          "role": {
            "type": "string",
            "nullable": true,
            "enum": [
              "admin",
              "invited",
              "partner",
              "coordinator",
              "agent",
              "custom",
              "trainer"
            ],
            "description": "Role of the member in the app (*Type* in the platform). The platform offers `admin`, `coordinator`, `agent` and `trainer`."
          },
          "agentType": {
            "type": "string",
            "nullable": true,
            "enum": [
              "digital",
              "floor"
            ],
            "description": "Only for `agent`, in automotive apps: whether the person works over chat (`digital`) or in person at the dealership (`floor`). `null` on any other role, and read as `digital`."
          },
          "isOwner": {
            "type": "boolean",
            "description": "`true` for the owner of the app. Each app has one."
          },
          "inactive": {
            "type": "boolean",
            "description": "`true` when the member is deactivated."
          },
          "inactiveAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "When the member was deactivated."
          },
          "inactiveReason": {
            "type": "string",
            "nullable": true,
            "description": "Why the member was deactivated."
          },
          "isViewAllSpaceChat": {
            "type": "boolean",
            "description": "`true` when the member sees the chats of every space, not only the ones assigned to them."
          },
          "isVisible": {
            "type": "boolean",
            "description": "`false` for a member inherited from a parent app of the network (for example, the brand or the distributor); those are listed only with `includeHidden`."
          },
          "inheritedFromAppUUID": {
            "type": "string",
            "nullable": true,
            "description": "For an inherited member, the `appUUID` of the parent app that gives the access. `null` for direct members."
          },
          "position": {
            "type": "string",
            "nullable": true,
            "description": "Job title (*Position* in the platform), as the key of the option, e.g. `salesAdvisor`, or free text. It grants no permissions."
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "The person's id in your own systems, e.g. `EMP-0231`."
          },
          "termsAcceptedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "When the member accepted the terms and conditions of the app. `null` if they have not."
          }
        }
      },
      "ApiKey": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "key": {
            "type": "string",
            "description": "The credential. For hashed keys only the public prefix is listed; the full key is returned once on creation."
          },
          "app": {
            "type": "string"
          },
          "generic": {
            "type": "boolean",
            "description": "`true` for the app's generic key: the platform creates it, and it belongs to the app itself rather than to a team member."
          },
          "createdAt": {
            "type": "string",
            "format": "date-time"
          },
          "expiredAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true
          },
          "owner": {
            "type": "object",
            "nullable": true,
            "properties": {
              "userId": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "lastName": {
                "type": "string",
                "nullable": true
              },
              "photo": {
                "type": "string",
                "nullable": true
              }
            }
          }
        }
      },
      "CreateApiKeyRequest": {
        "type": "object",
        "properties": {
          "expiredAt": {
            "type": "string",
            "format": "date-time",
            "description": "Optional. Without it, the key expires one year after it is created. If you send it, it must be in the future and at most 5 years ahead."
          }
        }
      },
      "AddMemberRequest": {
        "type": "object",
        "required": [
          "role"
        ],
        "description": "Identify the user by `userId` (numeric id or business id) OR `email`.",
        "properties": {
          "userId": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "string",
                "minLength": 1
              }
            ],
            "description": "Numeric user id or user business id."
          },
          "email": {
            "type": "string",
            "format": "email",
            "maxLength": 150
          },
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "invited",
              "partner",
              "coordinator",
              "agent",
              "custom",
              "trainer"
            ],
            "description": "Role of the member in the app (*Type* in the platform). The platform offers `admin`, `coordinator`, `agent` and `trainer`."
          },
          "agentType": {
            "type": "string",
            "enum": [
              "digital",
              "floor"
            ],
            "nullable": true,
            "description": "Only for `agent`, in automotive apps: whether the person works over chat (`digital`) or in person at the dealership (`floor`). `null` on any other role, and read as `digital`."
          }
        }
      },
      "TransferOwnerRequest": {
        "type": "object",
        "required": [
          "userId"
        ],
        "properties": {
          "userId": {
            "oneOf": [
              {
                "type": "integer",
                "minimum": 1
              },
              {
                "type": "string",
                "minLength": 1
              }
            ],
            "description": "Numeric id or business id of the new owner. It must be an active admin of the app."
          }
        }
      },
      "Jwks": {
        "type": "object",
        "properties": {
          "keys": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "kty": {
                  "type": "string"
                },
                "crv": {
                  "type": "string"
                },
                "x": {
                  "type": "string"
                },
                "y": {
                  "type": "string"
                },
                "kid": {
                  "type": "string"
                },
                "alg": {
                  "type": "string"
                },
                "use": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "Principal": {
        "type": "object",
        "required": [
          "active"
        ],
        "properties": {
          "active": {
            "type": "boolean",
            "description": "`false` when the credential is missing, invalid, expired or revoked. Then no other field comes."
          },
          "credentialType": {
            "type": "string",
            "enum": [
              "apikey",
              "jwt"
            ]
          },
          "user": {
            "type": "object",
            "description": "The user behind the credential. For an API key, the admin who created it.",
            "properties": {
              "uuid": {
                "type": "string",
                "description": "User UUID (the agent id in Smart Chat and Analytics)."
              },
              "userId": {
                "type": "string",
                "description": "User business id."
              },
              "email": {
                "type": "string",
                "nullable": true
              },
              "name": {
                "type": "string"
              },
              "lastName": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "app": {
            "type": "string",
            "nullable": true,
            "description": "appUUID the credential resolved to: the `x-app-uuid` you sent, or the app the API key belongs to."
          },
          "role": {
            "type": "string",
            "nullable": true,
            "enum": [
              "admin",
              "invited",
              "partner",
              "coordinator",
              "agent",
              "custom",
              "trainer",
              null
            ],
            "description": "Role of the user in that app. `null` if not a member."
          },
          "isMember": {
            "type": "boolean"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "When the credential expires. `null` only for older API keys created without an expiration date: new keys always expire (one year after creation by default)."
          }
        }
      },
      "OAuthError": {
        "type": "object",
        "description": "Standard OAuth 2.0 error (RFC 6749).",
        "properties": {
          "error": {
            "type": "string",
            "enum": [
              "invalid_request",
              "invalid_client",
              "unsupported_grant_type"
            ],
            "description": "RFC 6749 error code."
          },
          "error_description": {
            "type": "string",
            "description": "Detail of the error, when there is one."
          }
        }
      },
      "User": {
        "type": "object",
        "description": "A Biky user, with their profile.",
        "properties": {
          "uuid": {
            "type": "string",
            "description": "User UUID. It is the agent id in Smart Chat and Analytics."
          },
          "userId": {
            "type": "string",
            "description": "User business id."
          },
          "name": {
            "type": "string",
            "nullable": true
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "countryCode": {
            "type": "integer",
            "nullable": true,
            "description": "Phone country calling code, e.g. 57."
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "birthday": {
            "type": "string",
            "nullable": true,
            "description": "Date of birth, `YYYY-MM-DD`."
          },
          "identification": {
            "type": "object",
            "description": "ID document.",
            "properties": {
              "type": {
                "type": "string",
                "nullable": true,
                "description": "Document type."
              },
              "number": {
                "type": "string",
                "nullable": true,
                "description": "Document number."
              }
            }
          },
          "address": {
            "type": "object",
            "properties": {
              "country": {
                "type": "string",
                "nullable": true
              },
              "province": {
                "type": "string",
                "nullable": true
              },
              "city": {
                "type": "string",
                "nullable": true
              },
              "zone": {
                "type": "string",
                "nullable": true
              }
            }
          },
          "photo": {
            "type": "string",
            "nullable": true,
            "description": "Avatar URL"
          },
          "termsAccepted": {
            "type": "boolean",
            "description": "`true` when the user accepted the terms and conditions."
          },
          "lastAccessAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "Last time the user logged in."
          }
        }
      },
      "Membership": {
        "type": "object",
        "description": "Access of the user to one app.",
        "properties": {
          "appUUID": {
            "type": "string"
          },
          "role": {
            "type": "string",
            "nullable": true,
            "enum": [
              "admin",
              "invited",
              "partner",
              "coordinator",
              "agent",
              "custom",
              "trainer"
            ],
            "description": "Role of the member in the app (*Type* in the platform). The platform offers `admin`, `coordinator`, `agent` and `trainer`."
          },
          "agentType": {
            "type": "string",
            "nullable": true,
            "enum": [
              "digital",
              "floor"
            ],
            "description": "Only for `agent`, in automotive apps: whether the person works over chat (`digital`) or in person at the dealership (`floor`). `null` on any other role, and read as `digital`."
          },
          "isOwner": {
            "type": "boolean",
            "description": "`true` for the owner of the app. Each app has one."
          },
          "inactive": {
            "type": "boolean",
            "description": "`true` when the member is deactivated."
          },
          "inactiveAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "When the member was deactivated."
          },
          "inactiveReason": {
            "type": "string",
            "nullable": true,
            "description": "Why the member was deactivated."
          },
          "isViewAllSpaceChat": {
            "type": "boolean",
            "description": "`true` when the member sees the chats of every space, not only the ones assigned to them."
          },
          "isVisible": {
            "type": "boolean",
            "description": "`false` for a member inherited from a parent app of the network (for example, the brand or the distributor); those are listed only with `includeHidden`."
          },
          "inheritedFromAppUUID": {
            "type": "string",
            "nullable": true,
            "description": "For an inherited member, the `appUUID` of the parent app that gives the access. `null` for direct members."
          },
          "position": {
            "type": "string",
            "nullable": true,
            "description": "Job title (*Position* in the platform), as the key of the option, e.g. `salesAdvisor`, or free text. It grants no permissions."
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "description": "The person's id in your own systems, e.g. `EMP-0231`."
          },
          "termsAcceptedAt": {
            "type": "string",
            "nullable": true,
            "format": "date-time",
            "description": "When the member accepted the terms and conditions of the app. `null` if they have not."
          }
        }
      },
      "MeResponse": {
        "type": "object",
        "properties": {
          "user": {
            "$ref": "#/components/schemas/User"
          },
          "memberships": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Membership"
            },
            "description": "Apps the user belongs to, including the ones where they are deactivated."
          },
          "preferences": {
            "type": "object",
            "additionalProperties": true,
            "description": "User settings as key-value pairs."
          }
        }
      },
      "UserSummary": {
        "type": "object",
        "properties": {
          "uuid": {
            "type": "string",
            "description": "User UUID. It is the agent id in Smart Chat and Analytics."
          },
          "userId": {
            "type": "string",
            "description": "User business id."
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "photo": {
            "type": "string",
            "nullable": true,
            "description": "Avatar URL"
          }
        }
      },
      "UserProfile": {
        "type": "object",
        "properties": {
          "uuid": {
            "type": "string",
            "description": "User UUID. It is the agent id in Smart Chat and Analytics."
          },
          "userId": {
            "type": "string",
            "description": "User business id."
          },
          "email": {
            "type": "string",
            "nullable": true
          },
          "name": {
            "type": "string"
          },
          "lastName": {
            "type": "string",
            "nullable": true
          },
          "phone": {
            "type": "string",
            "nullable": true
          },
          "photo": {
            "type": "string",
            "nullable": true,
            "description": "Avatar URL"
          },
          "country": {
            "type": "string",
            "nullable": true
          },
          "countryCode": {
            "type": "integer",
            "nullable": true,
            "description": "Phone country calling code, e.g. 57."
          },
          "identification_type": {
            "type": "string",
            "nullable": true,
            "description": "Document type."
          },
          "identification": {
            "type": "string",
            "nullable": true,
            "description": "Document number."
          },
          "birthday": {
            "type": "string",
            "nullable": true,
            "description": "Date of birth, `YYYY-MM-DD`."
          },
          "address_country": {
            "type": "string",
            "nullable": true
          },
          "address_province": {
            "type": "string",
            "nullable": true
          },
          "address_city": {
            "type": "string",
            "nullable": true
          },
          "address_zone": {
            "type": "string",
            "nullable": true
          },
          "lang": {
            "type": "string",
            "nullable": true,
            "description": "Language of the emails Biky sends to the user."
          }
        }
      },
      "MemberPatchRequest": {
        "type": "object",
        "minProperties": 1,
        "description": "Send only the fields to change; at least one.",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "admin",
              "invited",
              "partner",
              "coordinator",
              "agent",
              "custom",
              "trainer"
            ],
            "description": "New role (*Type* in the platform). Only the owner of the app can make someone an admin or change the role of an admin."
          },
          "agentType": {
            "type": "string",
            "enum": [
              "digital",
              "floor"
            ],
            "nullable": true,
            "description": "Only for `agent`, in automotive apps: whether the person works over chat (`digital`) or in person at the dealership (`floor`). `null` on any other role, and read as `digital`."
          },
          "inactive": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "`1` deactivates the member and `0` reactivates them; `true` and `false` also work. The owner cannot be deactivated."
          },
          "inactiveReason": {
            "type": "string",
            "nullable": true,
            "maxLength": 255,
            "description": "Why you deactivate the member. Saved only when `inactive` changes their status."
          },
          "isViewAllSpaceChat": {
            "type": "integer",
            "enum": [
              0,
              1
            ],
            "description": "`1` lets the member see the chats of every space, not only the ones assigned to them; `0` limits them to their spaces. `true` and `false` also work."
          },
          "position": {
            "type": "string",
            "nullable": true,
            "maxLength": 255,
            "description": "Job title (*Position* in the platform), as the key of the option, e.g. `salesAdvisor`, or free text. An empty string or `null` clears it."
          },
          "externalId": {
            "type": "string",
            "nullable": true,
            "maxLength": 100,
            "description": "The person's id in your own systems, e.g. `EMP-0231`. An empty string or `null` clears it."
          }
        }
      }
    }
  },
  "security": [
    {
      "bearerAuth": []
    }
  ]
}
