---
title: "Create or update OAuth2 client registration template (saveClientRegistrationTemplate)

Available for users with 'SYS_ADMIN' authority."
method: POST
path: "/api/oauth2/config/template"
tags: ["o-auth-2-config-template-controller"]
---

# Create or update OAuth2 client registration template (saveClientRegistrationTemplate)

Available for users with 'SYS_ADMIN' authority.

`POST /api/oauth2/config/template`

Client registration template is OAuth2 provider configuration template with default settings for registering new OAuth2 clients

## Request body

- OAuth2ClientRegistrationTemplate
  - `id` OAuth2ClientRegistrationTemplateId
    - `id` string, uuid, required — string
  - `createdTime` integer — Entity creation timestamp in milliseconds since Unix epoch
  - `providerId` string, required — OAuth2 provider identifier (e.g. its name)
  - `mapperConfig` OAuth2MapperConfig
    - `allowUserCreation` boolean — Whether user should be created if not yet present on the platform after successful authentication
    - `activateUser` boolean — Whether user credentials should be activated when user is created after successful authentication
    - `type` 'BASIC' | 'CUSTOM' | 'GITHUB' | 'APPLE', required — Type of OAuth2 mapper. Depending on this param, different mapper config fields must be specified
    - `basic` OAuth2BasicMapperConfig
      - `emailAttributeKey` string — Email attribute key of OAuth2 principal attributes. Must be specified for BASIC mapper type and cannot be specified for GITHUB type
      - `firstNameAttributeKey` string — First name attribute key
      - `lastNameAttributeKey` string — Last name attribute key
      - `tenantNameStrategy` 'DOMAIN' | 'EMAIL' | 'CUSTOM', required — Tenant naming strategy. For DOMAIN type, domain for tenant name will be taken from the email (substring before '@')
      - `tenantNamePattern` string — Tenant name pattern for CUSTOM naming strategy. OAuth2 attributes in the pattern can be used by enclosing attribute key in '%{' and '}'
      - `customerNamePattern` string — Customer name pattern. When creating a user on the first OAuth2 log in, if specified, customer name will be used to create or find existing customer in the platform and assign customerId to the user
      - `defaultDashboardName` string — Name of the tenant's dashboard to set as default dashboard for newly created user
      - `alwaysFullScreen` boolean — Whether default dashboard should be open in full screen
    - `custom` OAuth2CustomMapperConfig
      - `url` string
      - `username` string
      - `password` string
      - `sendToken` boolean
  - `authorizationUri` string — Default authorization URI of the OAuth2 provider
  - `accessTokenUri` string — Default access token URI of the OAuth2 provider
  - `scope` string[] — Default OAuth scopes that will be requested from OAuth2 platform
  - `userInfoUri` string — Default user info URI of the OAuth2 provider
  - `userNameAttributeName` string — Default name of the username attribute in OAuth2 provider log in response
  - `jwkSetUri` string — Default JSON Web Key URI of the OAuth2 provider
  - `clientAuthenticationMethod` string — Default client authentication method to use: 'BASIC' or 'POST'
  - `comment` string — Comment for OAuth2 provider
  - `loginButtonIcon` string — Default log in button icon for OAuth2 provider
  - `loginButtonLabel` string — Default OAuth2 provider label
  - `helpLink` string — Help link for OAuth2 provider
  - `name` string
  - `additionalInfo` unknown

## Response `200`

OK

- OAuth2ClientRegistrationTemplate
  - `id` OAuth2ClientRegistrationTemplateId
    - `id` string, uuid, required — string
  - `createdTime` integer — Entity creation timestamp in milliseconds since Unix epoch
  - `providerId` string, required — OAuth2 provider identifier (e.g. its name)
  - `mapperConfig` OAuth2MapperConfig
    - `allowUserCreation` boolean — Whether user should be created if not yet present on the platform after successful authentication
    - `activateUser` boolean — Whether user credentials should be activated when user is created after successful authentication
    - `type` 'BASIC' | 'CUSTOM' | 'GITHUB' | 'APPLE', required — Type of OAuth2 mapper. Depending on this param, different mapper config fields must be specified
    - `basic` OAuth2BasicMapperConfig
      - `emailAttributeKey` string — Email attribute key of OAuth2 principal attributes. Must be specified for BASIC mapper type and cannot be specified for GITHUB type
      - `firstNameAttributeKey` string — First name attribute key
      - `lastNameAttributeKey` string — Last name attribute key
      - `tenantNameStrategy` 'DOMAIN' | 'EMAIL' | 'CUSTOM', required — Tenant naming strategy. For DOMAIN type, domain for tenant name will be taken from the email (substring before '@')
      - `tenantNamePattern` string — Tenant name pattern for CUSTOM naming strategy. OAuth2 attributes in the pattern can be used by enclosing attribute key in '%{' and '}'
      - `customerNamePattern` string — Customer name pattern. When creating a user on the first OAuth2 log in, if specified, customer name will be used to create or find existing customer in the platform and assign customerId to the user
      - `defaultDashboardName` string — Name of the tenant's dashboard to set as default dashboard for newly created user
      - `alwaysFullScreen` boolean — Whether default dashboard should be open in full screen
    - `custom` OAuth2CustomMapperConfig
      - `url` string
      - `username` string
      - `password` string
      - `sendToken` boolean
  - `authorizationUri` string — Default authorization URI of the OAuth2 provider
  - `accessTokenUri` string — Default access token URI of the OAuth2 provider
  - `scope` string[] — Default OAuth scopes that will be requested from OAuth2 platform
  - `userInfoUri` string — Default user info URI of the OAuth2 provider
  - `userNameAttributeName` string — Default name of the username attribute in OAuth2 provider log in response
  - `jwkSetUri` string — Default JSON Web Key URI of the OAuth2 provider
  - `clientAuthenticationMethod` string — Default client authentication method to use: 'BASIC' or 'POST'
  - `comment` string — Comment for OAuth2 provider
  - `loginButtonIcon` string — Default log in button icon for OAuth2 provider
  - `loginButtonLabel` string — Default OAuth2 provider label
  - `helpLink` string — Help link for OAuth2 provider
  - `name` string
  - `additionalInfo` unknown

---

[API](https://skmtc.net/thingsboard/apis/thingsboard-rest-api.md) · [All operations](https://skmtc.net/thingsboard/apis/thingsboard-rest-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/thingsboard/thingsboard-rest-api/revisions/40169ccdec5c/schema)
