{
  "openapi": "3.0.1",
  "info": {
    "title": "Auth Oauth",
    "version": "v1",
    "x-hubspot-product-tier-requirements": {
      "marketing": "FREE",
      "sales": "FREE",
      "service": "FREE",
      "cms": "FREE"
    },
    "x-hubspot-documentation-banner": "NONE",
    "x-jentic-source-url": "https://raw.githubusercontent.com/HubSpot/HubSpot-public-api-spec-collection/HEAD/PublicApiSpecs/Auth/Oauth/Rollouts/155908/v1/oauth.json"
  },
  "servers": [
    {
      "url": "https://api.hubapi.com"
    }
  ],
  "paths": {
    "/oauth/v1/access-tokens/{token}": {
      "get": {
        "tags": [
          "Access_Tokens"
        ],
        "summary": "Retrieve OAuth token metadata",
        "description": "Retrieve a token's metadata, including the email address of the user that the token was created for and the ID of the account it's associated with.\n\nNote: HubSpot access tokens will fluctuate in size as the information that's encoded in them changes over time. It's recommended to allow for tokens to be up to 300 characters to account for any potential changes.",
        "operationId": "get-/oauth/v1/access-tokens/{token}_get",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The access token that you want to retrieve information about.",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AccessTokenInfoResponse"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": []
      }
    },
    "/oauth/v1/refresh-tokens/{token}": {
      "get": {
        "tags": [
          "Refresh_Tokens"
        ],
        "summary": "Retrieve refresh token metadata",
        "description": "Retrieve a refresh token's metadata, including the email address of the user that the token was created for and the ID of the account it's associated with. Learn more about [refresh tokens](https://developers.hubspot.com/docs/guides/api/app-management/oauth-tokens#generate-initial-access-and-refresh-tokens).",
        "operationId": "get-/oauth/v1/refresh-tokens/{token}_get",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The refresh token to retrieve information about.",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RefreshTokenInfoResponse"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": []
      },
      "delete": {
        "tags": [
          "Refresh_Tokens"
        ],
        "summary": "Delete a refresh token",
        "description": "Delete a refresh token, typically after a user uninstalls your app. Access tokens generated with the refresh token will not be affected.\n \nThis will not uninstall the application from HubSpot or inhibit data syncing between an account and the app.",
        "operationId": "delete-/oauth/v1/refresh-tokens/{token}_archive",
        "parameters": [
          {
            "name": "token",
            "in": "path",
            "description": "The refresh token to delete.",
            "required": true,
            "style": "simple",
            "explode": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "204": {
            "description": "No content",
            "content": {}
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": []
      }
    },
    "/oauth/v1/token": {
      "post": {
        "tags": [
          "Tokens"
        ],
        "summary": "Refresh an access token",
        "description": "Use a [previously obtained refresh token](#get-oauth-2.0-access-and-refresh-tokens) to generate a new access token. \n\nAccess tokens are short lived. You can check the `expires_in` parameter when generating an access token to determine its lifetime (in seconds). If you need offline access to HubSpot data, store the refresh token you get when [initiating your OAuth integration](https://developers.hubspot.com/docs/guides/api/app-management/oauth-tokens#initiating-oauth-access) and use it to generate a new access token once the initial one expires.\n\n Note: HubSpot access tokens will fluctuate in size as the information that's encoded in them changes over time. It's recommended to allow for tokens to be up to 300 characters to account for any potential changes.",
        "operationId": "post-/oauth/v1/token_create",
        "parameters": [],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "authorization_code",
                      "refresh_token"
                    ]
                  },
                  "code": {
                    "type": "string"
                  },
                  "redirect_uri": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  },
                  "client_secret": {
                    "type": "string"
                  },
                  "refresh_token": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "successful operation",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponseIF"
                }
              }
            }
          },
          "default": {
            "$ref": "#/components/responses/Error"
          }
        },
        "security": []
      }
    }
  },
  "components": {
    "schemas": {
      "ErrorDetail": {
        "required": [
          "message"
        ],
        "type": "object",
        "properties": {
          "subCategory": {
            "type": "string",
            "description": "A specific category that contains more specific detail about the error"
          },
          "code": {
            "type": "string",
            "description": "The status code associated with the error detail"
          },
          "in": {
            "type": "string",
            "description": "The name of the field or parameter in which the error was found."
          },
          "context": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Context about the error condition",
            "example": {
              "missingScopes": [
                "scope1",
                "scope2"
              ]
            }
          },
          "message": {
            "type": "string",
            "description": "A human readable message describing the error along with remediation steps where appropriate"
          }
        }
      },
      "RefreshTokenInfoResponse": {
        "required": [
          "client_id",
          "hub_id",
          "scopes",
          "token",
          "token_type",
          "user_id"
        ],
        "type": "object",
        "properties": {
          "hub_id": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "user_id": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "scopes": {
            "type": "array",
            "description": "",
            "items": {
              "type": "string"
            }
          },
          "token_type": {
            "type": "string",
            "description": ""
          },
          "user": {
            "type": "string",
            "description": ""
          },
          "hub_domain": {
            "type": "string",
            "description": ""
          },
          "client_id": {
            "type": "string",
            "description": ""
          },
          "token": {
            "type": "string",
            "description": ""
          }
        }
      },
      "Error": {
        "required": [
          "category",
          "correlationId",
          "message"
        ],
        "type": "object",
        "properties": {
          "subCategory": {
            "type": "string",
            "description": "A specific category that contains more specific detail about the error"
          },
          "context": {
            "type": "object",
            "additionalProperties": {
              "type": "array",
              "items": {
                "type": "string"
              }
            },
            "description": "Context about the error condition",
            "example": {
              "missingScopes": [
                "scope1",
                "scope2"
              ],
              "invalidPropertyName": [
                "propertyValue"
              ]
            }
          },
          "correlationId": {
            "type": "string",
            "description": "A unique identifier for the request. Include this value with any error reports or support tickets",
            "format": "uuid",
            "example": "aeb5f871-7f07-4993-9211-075dc63e7cbf"
          },
          "links": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            },
            "description": "A map of link names to associated URIs containing documentation about the error or recommended remediation steps"
          },
          "message": {
            "type": "string",
            "description": "A human readable message describing the error along with remediation steps where appropriate",
            "example": "An error occurred"
          },
          "category": {
            "type": "string",
            "description": "The error category"
          },
          "errors": {
            "type": "array",
            "description": "further information about the error",
            "items": {
              "$ref": "#/components/schemas/ErrorDetail"
            }
          }
        },
        "example": {
          "message": "Invalid input (details will vary based on the error)",
          "correlationId": "aeb5f871-7f07-4993-9211-075dc63e7cbf",
          "category": "VALIDATION_ERROR",
          "links": {
            "knowledge-base": "https://www.hubspot.com/products/service/knowledge-base"
          }
        }
      },
      "AccessTokenInfoResponse": {
        "required": [
          "app_id",
          "expires_in",
          "hub_id",
          "scopes",
          "token",
          "token_type",
          "user_id"
        ],
        "type": "object",
        "properties": {
          "hub_id": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "user_id": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "scopes": {
            "type": "array",
            "description": "",
            "items": {
              "type": "string"
            }
          },
          "token_type": {
            "type": "string",
            "description": ""
          },
          "user": {
            "type": "string",
            "description": ""
          },
          "hub_domain": {
            "type": "string",
            "description": ""
          },
          "app_id": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "expires_in": {
            "type": "integer",
            "description": "",
            "format": "int32"
          },
          "token": {
            "type": "string",
            "description": ""
          }
        }
      },
      "TokenResponseIF": {
        "required": [
          "access_token",
          "expires_in",
          "refresh_token",
          "token_type"
        ],
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "description": ""
          },
          "refresh_token": {
            "type": "string",
            "description": ""
          },
          "id_token": {
            "type": "string",
            "description": ""
          },
          "token_type": {
            "type": "string",
            "description": ""
          },
          "expires_in": {
            "type": "integer",
            "description": "",
            "format": "int32"
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "An error occurred.",
        "content": {
          "*/*": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "securitySchemes": {}
  },
  "tags": [
    {
      "name": "Access_Tokens"
    },
    {
      "name": "Refresh_Tokens"
    },
    {
      "name": "Tokens"
    }
  ],
  "x-hubspot-available-client-libraries": [
    "PHP",
    "Node",
    "Ruby",
    "Python"
  ],
  "x-hubspot-product-tier-requirements": {
    "marketing": "FREE",
    "sales": "FREE",
    "service": "FREE",
    "cms": "FREE"
  },
  "x-hubspot-documentation-banner": "NONE"
}