create token.md
Create token
Create Access Token
The "Create Access Token" endpoint allows a user to generate new access and refresh tokens by providing their email and password. These tokens are essential for authenticating and authorizing API requests.
Authentication
- Include your
x-api-keyThe API key provided by GenLogs. This header must be included in the request.
Endpoint
- URL:
https://api.genlogs.io/auth/token - Method:
POST
Request Parameters
Credentials must be provided in the JSON request body.
Recommended: JSON request body
Send email and password in a JSON body with the Content-Type: application/json header. No URL-encoding of special characters is needed (e.g. 1234+ can be sent as-is).
curl -X POST 'https://api.genlogs.io/auth/token/'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-H 'x-api-key: {your_api_key}'
-d '{"email": "{email}", "password": "{password}"}'
Body schema:
{ "email": "user@example.com", "password": "your_password" }
Parameters
email(string, required): The email address of the user requesting the tokens.password(string, required): The password of the user for authentication.
Response
- 200 OK: Successfully generated and returned the access and refresh tokens.
- 401 Unauthorized: If the provided email, and password, resulting in a failure to create the tokens.
- 500 Internal Server Error: If an error occurs on the server during token creation.
Response Body
- access_token_data (TokenSchema): The schema representing the access token and its expiration.
- token (string): The access token string used for authentication and authorization.
- expires (datetime): The datetime when the access token expires.
- refresh_token_data (TokenSchema): The schema representing the refresh token and its expiration.
- token (string): The refresh token string used to obtain a new access token.
- expires (datetime): The datetime when the refresh token expires.
- user_id (int): The ID of the user for whom the tokens were created.
- company_id (int): The ID of the company associated with the authenticated user.
- customer_name (string): The name of the customer associated with the authenticated user.
Request Example:
curl -X POST 'https://api.genlogs.io/auth/token/?email={email}&password={password}' \
-H 'accept: application/json' \
-H 'x-api-key: {your_api_key}'
Create access and refresh tokens
Create and return new access and refresh tokens for a user based on their email and password.
{"openapi":"3.0.3","info":{"title":"Auth API - Create Token","version":"1.0.0"},"servers":[{"url":"https://api.genlogs.io","description":"GenLogs API"}],"paths":{"/auth/token":{"post":{"tags":["auth"],"summary":"Create access and refresh tokens","description":"Create and return new access and refresh tokens for a user based on their email and password.","operationId":"createAccessToken","parameters":[{"name":"email","in":"query","required":true,"schema":{"type":"string","format":"email"},"description":"Email of the user requesting tokens."},{"name":"password","in":"query","required":true,"schema":{"type":"string","format":"password"},"description":"Password of the user requesting tokens."}],"responses":{"200":{"description":"Access and refresh tokens created successfully.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/AuthSchema"}}}},"401":{"description":"Token creation failed because credentials are invalid.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPError"}}}},"422":{"description":"Request validation error.","content":{"application/json":{"schema":{"$ref":"#/components/schemas/HTTPValidationError"}}}}}}}},"components":{"schemas":{"AuthSchema":{"type":"object","required":["access_token_data","refresh_token_data","user_id"],"properties":{"access_token_data":{"$ref":"#/components/schemas/TokenSchema"},"refresh_token_data":{"$ref":"#/components/schemas/TokenSchema"},"user_id":{"type":"integer"},"company_id":{"type":"integer","nullable":true},"customer_name":{"type":"string","nullable":true}}},"TokenSchema":{"type":"object","required":["token","expires"],"properties":{"token":{"type":"string"},"expires":{"type":"string","format":"date-time"}}},"HTTPError":{"type":"object","properties":{"detail":{"type":"string"}}},"HTTPValidationError":{"type":"object","properties":{"detail":{"type":"array","items":{"$ref":"#/components/schemas/ValidationError"}}}},"ValidationError":{"type":"object","required":["loc","msg","type"],"properties":{"loc":{"type":"array","items":{"oneOf":[{"type":"string"},{"type":"integer"}]}},"msg":{"type":"string"},"type":{"type":"string"}}}}}}