{
  "security": [
    {
      "accountSid_authToken": []
    }
  ],
  "openapi": "3.0.1",
  "info": {
    "title": "User OAuth API",
    "description": "User OAuth API",
    "termsOfService": "https://www.twilio.com/legal/tos",
    "contact": {
      "name": "Twilio Support",
      "url": "https://support.twilio.com",
      "email": "support@twilio.com"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "https://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.0",
    "x-twilio": {
      "apiStandards": "v0.1"
    }
  },
  "servers": [
    {
      "url": "https://oauth.twilio.com"
    }
  ],
  "paths": {
    "/v2/token": {
      "x-twilio": {
        "defaultOutputProperties": [],
        "pathType": "list"
      },
      "post": {
        "security": [],
        "tags": [
          "OauthV2Token"
        ],
        "summary": "Issues a new Access token (optionally identity_token & refresh_token) in exchange of Oauth grant",
        "operationId": "CreateOauth2Token",
        "parameters": [
          {
            "name": "account_sid",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Optional Account SID to perform on behalf of requests."
          }
        ],
        "requestBody": {
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "title": "CreateTokenRequest",
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "description": "Grant type is a credential representing resource owner's authorization which can be used by client to obtain access token."
                  },
                  "client_id": {
                    "type": "string",
                    "description": "A 34 character string that uniquely identifies this OAuth App."
                  },
                  "client_secret": {
                    "type": "string",
                    "description": "The credential for confidential OAuth App."
                  },
                  "code": {
                    "type": "string",
                    "description": "JWT token related to the authorization code grant type."
                  },
                  "redirect_uri": {
                    "type": "string",
                    "description": "The redirect uri"
                  },
                  "audience": {
                    "type": "string",
                    "description": "The targeted audience uri"
                  },
                  "refresh_token": {
                    "type": "string",
                    "description": "JWT token related to refresh access token."
                  },
                  "scope": {
                    "type": "string",
                    "description": "The scope of token"
                  }
                }
              },
              "examples": {
                "create": {
                  "value": {
                    "client_id": "OQ7cda1a615f05a95634e643aaaf7081d7",
                    "client_secret": "sUWblrQ4wx_aYkdAWjHXNvHinynkYOgBoiRyEQUeEntpgDEG47qnBFD98yoEzsTh",
                    "grant_type": "client_credentials",
                    "redirect_uri": "",
                    "audience": "",
                    "code": "",
                    "refresh_token": "refresh_token",
                    "scope": "scope"
                  }
                }
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/V2Oauth2TokenResponse"
                },
                "examples": {
                  "create": {
                    "value": {
                      "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
                      "refresh_token": "ghjbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
                      "id_token": "eyJhbdGciOiIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
                      "expires_in": 1438315200000,
                      "token_type": "bearer"
                    }
                  }
                }
              }
            },
            "description": "Created"
          },
          "400": {
            "$ref": "#/components/responses/ErrorClientErrorResponse"
          },
          "500": {
            "$ref": "#/components/responses/ErrorResponse"
          }
        }
      }
    },
    "/v2/authorize": {
      "x-twilio": {
        "defaultOutputProperties": [
          "redirect_to"
        ],
        "pathType": "list"
      },
      "get": {
        "security": [],
        "tags": [
          "OauthV2Authorize"
        ],
        "summary": "Retrieves authorize uri",
        "operationId": "FetchOauth2Authorize",
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "code"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "OQ7cda1a615f05a95634e643aaaf7081d7"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "www.twilio.com"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "offline_access"
            }
          },
          {
            "name": "state",
            "in": "query",
            "schema": {
              "type": "string",
              "example": "xvz"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/oauth.v2.authorize"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "accountSid_authToken": {
        "scheme": "basic",
        "type": "http"
      },
      "v2_oauth2_client_credentials": {
        "type": "oauth2",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://oauth.twilio.com/v2/token",
            "scopes": {}
          }
        }
      }
    },
    "schemas": {
      "Auth0SignupRequest": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "deeplink": {
            "type": "string"
          },
          "organizationSid": {
            "pattern": "OR[0-9a-f]{32}",
            "type": "string",
            "format": "OrganizationSid",
            "example": "ORbfd75767416fbd8418bedafce743700a"
          },
          "notificationSid": {
            "pattern": "NF[0-9a-f]{32}",
            "type": "string",
            "format": "IdentityNotificationSid",
            "example": "NFbfd75767416fbd8418bedafce743700a"
          },
          "oneConsole": {
            "type": "boolean"
          }
        }
      },
      "Auth0AuthenticationCodeExchangeRequest": {
        "required": [
          "authorizationCode"
        ],
        "type": "object",
        "properties": {
          "authorizationCode": {
            "type": "string"
          },
          "state": {
            "type": "string"
          },
          "codeVerifier": {
            "type": "string"
          },
          "nonce": {
            "type": "string"
          }
        }
      },
      "Auth0AuthorizeResponse": {
        "required": [
          "redirect"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "redirect": {
            "type": "string"
          },
          "isSso": {
            "type": "boolean"
          }
        }
      },
      "Auth0TokenResponse": {
        "required": [
          "accessToken",
          "idToken",
          "authContext",
          "isPurgatory"
        ],
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "idToken": {
            "type": "string"
          },
          "authContext": {
            "type": "string"
          },
          "isPurgatory": {
            "type": "boolean"
          }
        }
      },
      "Auth0RefreshScopedTokenRequest": {
        "type": "object",
        "properties": {
          "accountSid": {
            "type": "string",
            "maxLength": 34,
            "pattern": "^AC[0-9a-fA-F]{32}$",
            "description": "The SID of the account to be authorized for the user."
          },
          "organizationSid": {
            "pattern": "OR[0-9a-f]{32}",
            "type": "string",
            "format": "OrganizationSid",
            "example": "ORbfd85878416fbd8418bedafce743700a"
          },
          "authorizationContext": {
            "type": "string",
            "enum": [
              "account",
              "user",
              "organization"
            ]
          },
          "active": {
            "type": "boolean",
            "description": "Whether this request represents user activity (true) or polling (false)",
            "default": true
          }
        }
      },
      "Auth0RefreshTokenResponse": {
        "required": [
          "accessToken"
        ],
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          }
        }
      },
      "Auth0RefreshTokenHeartbeatResponse": {
        "required": [
          "isValid"
        ],
        "type": "object",
        "properties": {
          "isValid": {
            "type": "boolean",
            "description": "True if session is valid, false if expired or invalid"
          },
          "expiresAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "datetime string when the session expires, only present if isValid is true"
          },
          "lastActiveAt": {
            "type": "string",
            "format": "date-time",
            "nullable": true,
            "description": "datetime string when the session was refreshed, only present if isValid is true"
          }
        }
      },
      "Auth0LoginEmailRequest": {
        "required": [
          "email"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "callbackUri": {
            "type": "string"
          },
          "returnTo": {
            "type": "string"
          },
          "g": {
            "type": "string"
          },
          "t": {
            "type": "string"
          }
        }
      },
      "Auth0TestLoginRequest": {
        "required": [
          "email",
          "password"
        ],
        "type": "object",
        "properties": {
          "email": {
            "type": "string"
          },
          "password": {
            "type": "string"
          }
        }
      },
      "Auth0TestLoginResponse": {
        "required": [
          "accessToken"
        ],
        "type": "object",
        "properties": {
          "accessToken": {
            "type": "string"
          },
          "idToken": {
            "type": "string"
          }
        }
      },
      "V2Oauth2TokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "nullable": true,
            "description": "Token which carries the necessary information to access a Twilio resource directly."
          },
          "refresh_token": {
            "type": "string",
            "nullable": true,
            "description": "Token which carries the information necessary to get a new access token."
          },
          "id_token": {
            "type": "string",
            "nullable": true,
            "description": "Token which carries the information necessary of user profile."
          },
          "token_type": {
            "type": "string",
            "nullable": true,
            "description": "Token type"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        }
      },
      "V2Oauth2ServiceTokenResponse": {
        "type": "object",
        "properties": {
          "access_token": {
            "type": "string",
            "nullable": true,
            "description": "Token which carries the necessary information to access a Twilio resource directly."
          },
          "token_type": {
            "type": "string",
            "nullable": true,
            "description": "Token type"
          },
          "expires_in": {
            "type": "integer",
            "format": "int64",
            "nullable": true
          }
        }
      },
      "oauth.v2.authorize": {
        "type": "object",
        "properties": {
          "redirect_to": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "The callback URL"
          }
        }
      },
      "V2OauthAuth0CallbackResponse": {
        "type": "object",
        "properties": {
          "redirect_to": {
            "type": "string",
            "format": "uri",
            "nullable": true,
            "description": "The redirect URL"
          }
        }
      },
      "SessionMetadataResponse": {
        "type": "object",
        "required": [
          "isHipaaUser",
          "sessionIdleTimeout",
          "isVerificationRequired"
        ],
        "properties": {
          "isHipaaUser": {
            "type": "boolean"
          },
          "sessionIdleTimeout": {
            "type": "integer"
          },
          "isVerificationRequired": {
            "type": "boolean"
          }
        }
      },
      "Error": {
        "description": "Generic error",
        "type": "object",
        "properties": {
          "code": {
            "description": "Twilio-specific error code",
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "description": "Error message",
            "type": "string"
          },
          "more_info": {
            "description": "Link to Error Code References",
            "type": "string"
          },
          "status": {
            "description": "HTTP response status code",
            "type": "integer",
            "format": "int32"
          }
        }
      },
      "ErrorThrottled": {
        "description": "Generic error",
        "type": "object",
        "properties": {
          "code": {
            "description": "Twilio-specific error code",
            "type": "integer",
            "format": "int32"
          },
          "message": {
            "description": "Error message",
            "type": "string"
          },
          "more_info": {
            "description": "Link to Error Code References",
            "type": "string"
          },
          "status": {
            "description": "HTTP response status code",
            "type": "integer",
            "format": "int32"
          },
          "throttled_until": {
            "description": "how long request is throttled for",
            "type": "string",
            "format": "date-time"
          }
        }
      }
    },
    "headers": {
      "Access-Control-Max-Age": {
        "description": "Indicates how long the results of preflight request can be cached for",
        "schema": {
          "type": "integer",
          "example": 3600
        }
      }
    },
    "responses": {
      "ErrorClientErrorResponse": {
        "description": "Client provided invalid parameters response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "client_error": {
                "value": {
                  "code": 400,
                  "message": "bad request",
                  "more_info": "https://www.twilio.com/docs/errors/400",
                  "status": 400
                }
              }
            }
          }
        }
      },
      "ErrorClientErrorResponseThrottled": {
        "description": "Request was throttled",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/ErrorThrottled"
            },
            "examples": {
              "client_error": {
                "value": {
                  "code": 400,
                  "message": "bad request",
                  "more_info": "https://www.twilio.com/docs/errors/400",
                  "status": 400
                }
              }
            }
          }
        }
      },
      "ErrorResponse": {
        "description": "Generic error response",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            },
            "examples": {
              "internal_server_error": {
                "value": {
                  "code": 20500,
                  "message": "internal server error",
                  "more_info": "https://www.twilio.com/docs/errors/20500",
                  "status": 500
                }
              }
            }
          }
        }
      }
    }
  }
}