---
title: "Obter token."
url: "https://devcenter.stone.com.br/apis/stone-tax/versions/206fd1c1-6382-4ada-8612-c67fdc65e050/paths/api-v1-Autenticacao-ObterToken/post"
---

> Full API specification: https://devcenter.stone.com.br/apis/stone-tax/versions/206fd1c1-6382-4ada-8612-c67fdc65e050.md

# Obter token.

`POST` `/api/v1/Autenticacao/ObterToken`

Permite obter o token de acesso a api com base nas credenciais fornecidas pelo operador do serviço. ⚠️ **ATENÇÃO**: O token tem validade de 1 hora. É sugerido armazenar o token em cache para evitar geração de tokens em excesso sobrecarregando o serviço.

## Request body

Content types: `application/json-patch+json`, `application/json`, `text/json`, `application/*+json`

## Responses

- `200` - OK
- `400` - Bad Request
- `401` - Unauthorized
- `500` - Internal Server Error

## OpenAPI definition

```yaml
openapi: 3.0.4
info:
  title: Stone Tax API
  version: 1.0.0
servers:
  - url: https://stone-tax-sdx.stone.com.br
    description: Ambiente de Desenvolvimento
  - url: https://stone-tax.stone.com.br
    description: Ambiente de Produção
paths:
  /api/v1/Autenticacao/ObterToken:
    post:
      tags:
        - Autenticacao
      summary: Obter token.
      description: >-
        Permite obter o token de acesso a api com base nas credenciais
        fornecidas pelo operador do serviço. 


        ⚠️ **ATENÇÃO**: O token tem validade de 1 hora. É sugerido armazenar o
        token em cache para evitar geração de tokens em excesso sobrecarregando
        o serviço.
      requestBody:
        description: Credenciais de acesso.
        content:
          application/json-patch+json:
            schema:
              $ref: "#/components/schemas/GerarTokenInputModel"
          application/json:
            schema:
              $ref: "#/components/schemas/GerarTokenInputModel"
          text/json:
            schema:
              $ref: "#/components/schemas/GerarTokenInputModel"
          application/*+json:
            schema:
              $ref: "#/components/schemas/GerarTokenInputModel"
      responses:
        "200":
          description: OK
          content:
            text/plain:
              schema:
                $ref: "#/components/schemas/GerarTokenViewModel"
            application/json:
              schema:
                $ref: "#/components/schemas/GerarTokenViewModel"
            text/json:
              schema:
                $ref: "#/components/schemas/GerarTokenViewModel"
        "400":
          description: Bad Request
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResponseErrorResult"
        "401":
          description: Unauthorized
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResponseErrorResult"
        "500":
          description: Internal Server Error
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/ResponseErrorResult"
components:
  schemas:
    GerarTokenInputModel:
      required:
        - clientId
        - secretId
      type: object
      properties:
        clientId:
          minLength: 1
          type: string
          description: Identificador do cliente da requisição.
        secretId:
          minLength: 1
          type: string
          description: Senha do cliente da requisição.
      additionalProperties: false
      description: Dados para gerar token de acesso.
    GerarTokenViewModel:
      type: object
      properties:
        token:
          type: string
          description: Token de acesso.
          nullable: true
        expiresIn:
          type: integer
          description: Tempo de expiração do token (segundos).
          format: int32
        refreshExpiresIn:
          type: integer
          description: Tempo de expiração do token para gerar nova sessão (segundos).
          format: int32
      additionalProperties: false
      description: Informação de retorno da autenticação.
    ResponseErrorResult:
      type: object
      properties:
        status:
          type: integer
          format: int32
        titulo:
          type: string
          nullable: true
        erros:
          type: object
          additionalProperties:
            type: array
            items:
              type: string
          nullable: true
      additionalProperties: false
```
