---
agentTools:
  projectIndex: https://seafile-api.readme.io/llms.txt
---

# Obtain account token

Generate an *Account-Token* with your username and password. This Account-Token is necessary for all the following account operations.
Use the optional paramater if two-factor-authentication (2FA) is activated for your account.

# OpenAPI definition

```json
{
  "openapi": "3.0.3",
  "info": {
    "title": "authentication",
    "description": "The official Seafile API Reference",
    "version": "13.0"
  },
  "tags": [
    {
      "name": "Account-Token",
      "description": "Access library with Account-Token"
    }
  ],
  "servers": [
    {
      "url": "https://{server}",
      "variables": {
        "server": {
          "default": "cloud.seafile.com"
        }
      }
    }
  ],
  "components": {
    "parameters": {
      "X-SEAFILE-OTP": {
        "name": "X-SEAFILE-OTP",
        "in": "header",
        "schema": {
          "type": "string",
          "pattern": "^\\d{6}$"
        },
        "description": "Two-factor token (usually generated with a mobile app like the google authenticator), optional, only needed if 2FA is activated for your account.\n"
      }
    },
    "schemas": {
      "AccountTokenResponse": {
        "type": "object",
        "description": "account-token",
        "properties": {
          "token": {
            "type": "string",
            "example": "25285a3da6fff1f7a6f9c9abc8da12dcd2bd4470",
            "minLength": 40,
            "maxLength": 40
          }
        }
      }
    }
  },
  "paths": {
    "/api2/auth-token/": {
      "post": {
        "summary": "Obtain account token",
        "tags": [
          "Account-Token"
        ],
        "description": "Generate an *Account-Token* with your username and password. This Account-Token is necessary for all the following account operations.\nUse the optional paramater if two-factor-authentication (2FA) is activated for your account.\n",
        "security": [],
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "username": {
                    "type": "string",
                    "description": "email address"
                  },
                  "password": {
                    "type": "string",
                    "description": "password"
                  }
                },
                "required": [
                  "username",
                  "password"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/X-SEAFILE-OTP"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccountTokenResponse"
                }
              }
            }
          }
        }
      }
    }
  },
  "x-readme": {
    "explorer-enabled": true,
    "proxy-enabled": true
  },
  "_id": {
    "buffer": {
      "0": 103,
      "1": 183,
      "2": 248,
      "3": 230,
      "4": 103,
      "5": 20,
      "6": 160,
      "7": 0,
      "8": 41,
      "9": 50,
      "10": 176,
      "11": 72
    }
  }
}
```