OAuth Scopes API

On this page
Essentials plan required

This feature requires at least an Essentials plan.

Available since 1.50.0

This page contains the APIs for managing the OAuth Scopes of an Application.

Create an OAuth Scope#

This API is used to create an OAuth Scope for an Application. Specifying an Id on the URI will instruct FusionAuth to use that Id when creating the OAuth Scope. Otherwise, FusionAuth will generate an Id for the OAuth Scope.

Request#

Create an OAuth Scope with either a randomly generated Id or one you provide on the URI.

API Key Authentication
Create an OAuth Scope with a randomly generated Id
POST/api/application/{applicationId}/scope
OpenAPI Spec
API Key Authentication
Create an OAuth Scope with a provided unique Id
POST/api/application/{applicationId}/scope/{scopeId}
OpenAPI Spec

Request Headers#

X-FusionAuth-TenantId
  • Type: String
  • Optional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See Making an API request using a Tenant Id for additional information.

Path Parameters#

applicationId
  • Type: UUID
  • Required

The Id of the Application.

scopeId
  • Type: UUID
  • Optional
  • Defaults to secure random UUID
  • Immutable

The Id to use for the new OAuth Scope. If not specified a secure random UUID will be generated.

Request Body#
scope.data
  • Type: Object
  • Optional

An object that can hold any information about the OAuth Scope that should be persisted.

scope.defaultConsentDetail
  • Type: String
  • Optional

The default detail to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.

scope.defaultConsentMessage
  • Type: String
  • Optional

The default message to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.

scope.description
  • Type: String
  • Optional

A description of the OAuth Scope for internal use.

scope.name
  • Type: String
  • Required

The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.

scope.required
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if the OAuth Scope is required when requested in an OAuth workflow.

Example Request JSON
{
  "scope": {
    "data": {
      "addedBy": "richard"
    },
    "defaultConsentDetail": "This will provide the requesting application read-only access to your data",
    "defaultConsentMessage": "View your data",
    "description": "Provides an application read-only access to a user's data",
    "name": "data:read",
    "required": true
  }
}

Response#

The response for this API contains the information for the OAuth Scope that was created.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes.

Response Body#

scope.applicationId
  • Type: UUID

The unique Id of the Application.

scope.data
  • Type: Object

An object that can hold any information about the OAuth Scope that should be persisted.

scope.defaultConsentDetail
  • Type: String

The default detail to display on the OAuth consent screen if one cannot be found in the theme.

scope.defaultConsentMessage
  • Type: String

The default message to display on the OAuth consent screen if one cannot be found in the theme.

scope.description
  • Type: String

A description of the OAuth Scope for internal use.

scope.id
  • Type: UUID

The unique Id of the OAuth Scope.

scope.insertInstant
  • Type: Long

The instant that the OAuth Scope was added to the FusionAuth database.

scope.lastUpdateInstant
  • Type: Long

The instant that the OAuth Scope was updated in the FusionAuth database.

scope.name
  • Type: String

The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.

scope.required
  • Type: Boolean

Determines if the OAuth Scope is required when requested in an OAuth workflow.

Example Response JSON
{
  "scope": {
    "applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
    "data": {
      "addedBy": "richard"
    },
    "defaultConsentDetail": "This will provide the requesting application read-only access to your data",
    "defaultConsentMessage": "View your data",
    "description": "Provides an application read-only access to a user's data",
    "id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
    "insertInstant": 1712268302394,
    "lastUpdateInstant": 1712268302394,
    "name": "data:read",
    "required": true
  }
}

Retrieve an OAuth Scope#

This API is used to retrieve a single OAuth Scope for an Application by unique Id.

Request#

Retrieve the OAuth Scope by its Id.

API Key Authentication
Retrieve an OAuth Scope by Id
GET/api/application/{applicationId}/scope/{scopeId}
OpenAPI Spec

Request Headers#

X-FusionAuth-TenantId
  • Type: String
  • Optional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See Making an API request using a Tenant Id for additional information.

Path Parameters#

applicationId
  • Type: UUID
  • Required

The Id of the Application.

scopeId
  • Type: UUID
  • Required

The Id of the OAuth Scope to retrieve.

Response#

The response for this API contains a single OAuth Scope.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
404The object you requested doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty.

Response Body#

scope.applicationId
  • Type: UUID

The unique Id of the Application.

scope.data
  • Type: Object

An object that can hold any information about the OAuth Scope that should be persisted.

scope.defaultConsentDetail
  • Type: String

The default detail to display on the OAuth consent screen if one cannot be found in the theme.

scope.defaultConsentMessage
  • Type: String

The default message to display on the OAuth consent screen if one cannot be found in the theme.

scope.description
  • Type: String

A description of the OAuth Scope for internal use.

scope.id
  • Type: UUID

The unique Id of the OAuth Scope.

scope.insertInstant
  • Type: Long

The instant that the OAuth Scope was added to the FusionAuth database.

scope.lastUpdateInstant
  • Type: Long

The instant that the OAuth Scope was updated in the FusionAuth database.

scope.name
  • Type: String

The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.

scope.required
  • Type: Boolean

Determines if the OAuth Scope is required when requested in an OAuth workflow.

Example Response JSON
{
  "scope": {
    "applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
    "data": {
      "addedBy": "richard"
    },
    "defaultConsentDetail": "This will provide the requesting application read-only access to your data",
    "defaultConsentMessage": "View your data",
    "description": "Provides an application read-only access to a user's data",
    "id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
    "insertInstant": 1712268302394,
    "lastUpdateInstant": 1712268302394,
    "name": "data:read",
    "required": true
  }
}

Update an OAuth Scope#

This API is used to update an existing OAuth Scope.

You must specify all of the properties of the OAuth Scope when calling this API with the PUT HTTP method. When used with PUT, this API doesn't merge the existing OAuth Scope and your new data. It replaces the existing OAuth Scope with your new data.

Utilize the PATCH HTTP method to send specific changes to merge into an existing OAuth Scope.

Note

When updating an OAuth Scope on a universal application, a global API key is required. A tenant-scoped API key is not sufficient for this operation.

Request#

Send the full OAuth Scope with your changes applied.

API Key Authentication
Update an OAuth Scope by Id
PUT/api/application/{applicationId}/scope/{scopeId}
OpenAPI Spec
PATCH/api/application/{applicationId}/scope/{scopeId}
OpenAPI Spec
Note

For backward compatibility, a PATCH request with a Content-Type of application/json accepts the same body as the PUT request. FusionAuth merges the request into the existing object:

  • FusionAuth keeps every field that the request leaves out, so send only the fields you want to change.
  • FusionAuth merges a map, such as data, by key. To remove a key, set the key to null.
  • FusionAuth appends the values in a request array to the existing array, unless this API documents otherwise. An empty array leaves the existing array unchanged, so you can't remove values from an appending array.
  • FusionAuth adds each object in an array of objects as a new element. FusionAuth doesn't match the object to an existing element by Id or by position.
  • Don't send a value that an array of Ids already contains, such as a key Id or a Tenant Id. Some of these arrays then return a 500 status code.
  • Don't set an array to null. Depending on the field, FusionAuth clears the array or returns a 500 status code.

To remove values from an array, PUT the full object, or set the Content-Type to one of the following media types:

For more information, see The PATCH HTTP Method.

Request Headers#

X-FusionAuth-TenantId
  • Type: String
  • Optional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See Making an API request using a Tenant Id for additional information.

Path Parameters#

applicationId
  • Type: UUID
  • Required

The Id of the Application.

scopeId
  • Type: UUID
  • Required
  • Immutable

The Id of the OAuth Scope to update.

Request Body#
scope.data
  • Type: Object
  • Optional

An object that can hold any information about the OAuth Scope that should be persisted.

scope.defaultConsentDetail
  • Type: String
  • Optional

The default detail to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.

scope.defaultConsentMessage
  • Type: String
  • Optional

The default message to display on the OAuth consent screen if one cannot be found in the theme. Learn more about setting this value using themes.

scope.description
  • Type: String
  • Optional

A description of the OAuth Scope for internal use.

scope.name
  • Type: String
  • Optional

The name of the OAuth Scope. The name can't be changed. Omit it or send the current name. To rename a scope, create a new scope and delete the old one.

scope.required
  • Type: Boolean
  • Optional
  • Defaults to false

Determines if the OAuth Scope is required when requested in an OAuth workflow.

Example Request JSON
{
  "scope": {
    "data": {
      "addedBy": "richard",
      "internal": false
    },
    "defaultConsentDetail": "This scope will provide the requesting application read-only access to your data",
    "defaultConsentMessage": "View data",
    "description": "Provides an application read access to a user's data",
    "required": false
  }
}

Response#

The response for this API contains the information for the OAuth Scope that was updated.

Response Codes
CodeDescription
200The request succeeded. The response contains a JSON body.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
404The object you're updating doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response usually contains an Errors JSON object with the [Exception] general error code. On MySQL, a data field larger than the database column also returns 500. For more information, see Data Field Sizes.

Response Body#

scope.applicationId
  • Type: UUID

The unique Id of the Application.

scope.data
  • Type: Object

An object that can hold any information about the OAuth Scope that should be persisted.

scope.defaultConsentDetail
  • Type: String

The default detail to display on the OAuth consent screen if one cannot be found in the theme.

scope.defaultConsentMessage
  • Type: String

The default message to display on the OAuth consent screen if one cannot be found in the theme.

scope.description
  • Type: String

A description of the OAuth Scope for internal use.

scope.id
  • Type: UUID

The unique Id of the OAuth Scope.

scope.insertInstant
  • Type: Long

The instant that the OAuth Scope was added to the FusionAuth database.

scope.lastUpdateInstant
  • Type: Long

The instant that the OAuth Scope was updated in the FusionAuth database.

scope.name
  • Type: String

The name of the OAuth Scope. This is the value that will be used to request the scope in OAuth workflows.

scope.required
  • Type: Boolean

Determines if the OAuth Scope is required when requested in an OAuth workflow.

Example Response JSON
{
  "scope": {
    "applicationId": "8c9f82c8-0926-4c6c-b8be-1bcface5b378",
    "data": {
      "addedBy": "richard",
      "internal": false
    },
    "defaultConsentDetail": "This scope will provide the requesting application read-only access to your data",
    "defaultConsentMessage": "View data",
    "description": "Provides an application read access to a user's data",
    "id": "f32b777a-8cc4-4233-afcf-d4c42d3ca488",
    "insertInstant": 1712268302394,
    "lastUpdateInstant": 1712298702394,
    "name": "data:read",
    "required": false
  }
}

Delete an OAuth Scope#

This API is used to permanently delete an OAuth Scope.

Note

When deleting an OAuth Scope on a universal application, a global API key is required. A tenant-scoped API key is not sufficient for this operation.

Request#

Delete the OAuth Scope by its Id.

API Key Authentication
Delete an OAuth Scope by Id
DELETE/api/application/{applicationId}/scope/{scopeId}
OpenAPI Spec

Path Parameters#

applicationId
  • Type: UUID
  • Required

The Id of the Application.

scopeId
  • Type: UUID
  • Required

The Id of the OAuth Scope to delete.

Request Headers#

X-FusionAuth-TenantId
  • Type: String
  • Optional

The unique Id of the tenant used to scope this API request.

The tenant Id is not required on this request even when more than one tenant has been configured because the tenant can be identified based upon other values in the request or it is otherwise not required.

Specify a tenant Id on this request when you want to ensure the request is scoped to a specific tenant. The tenant Id may be provided through this header or by using a tenant locked API key to achieve the same result.

See Making an API request using a Tenant Id for additional information.

Response#

This API does not return a JSON response body.

Response Codes
CodeDescription
200The request succeeded.
400The request was invalid or malformed. The response contains an Errors JSON object with the specific errors. FusionAuth also returns a 400 when the request needs a paid FusionAuth license and no license is present.
401FusionAuth didn't authorize the request. The Authorization header is missing, the API key isn't valid, or the API key doesn't have permission for this endpoint and method. The response is empty. For more information, see Unauthorized Responses.
404The object you requested doesn't exist. The response is empty.
500FusionAuth had an internal error and logged a stack trace in the FusionAuth log files. The response is empty.