Skip to main content

Overview

The ApplicationServiceApi provides methods for managing applications in Zitadel. Applications can be OIDC, API, or SAML types, and this API handles their configuration, keys, and lifecycle.

Initialize the API

require 'zitadel/client'

client = Zitadel::Client::ApiClient.new
client.config.access_token = 'YOUR_ACCESS_TOKEN'

app_api = Zitadel::Client::Api::ApplicationServiceApi.new(client)

Application Management

Create an application. The application can be OIDC, API or SAML type.Required permission: project.app.write
# Create an OIDC web application
request = Zitadel::Client::ApplicationServiceCreateApplicationRequest.new(
  project_id: 'project_123',
  name: 'My Web Application',
  oidc_config: {
    redirect_uris: ['https://myapp.com/callback'],
    response_types: ['OIDC_RESPONSE_TYPE_CODE'],
    grant_types: ['OIDC_GRANT_TYPE_AUTHORIZATION_CODE'],
    app_type: 'OIDC_APP_TYPE_WEB',
    auth_method_type: 'OIDC_AUTH_METHOD_TYPE_BASIC'
  }
)

response = app_api.create_application(request)
puts "Application ID: #{response.app_id}"
puts "Client ID: #{response.client_id}"
puts "Client Secret: #{response.client_secret}"
app_id
string
The ID of the created application
client_id
string
The client ID for OIDC applications
Retrieves the application matching the provided ID.Required permission: project.app.read
request = Zitadel::Client::ApplicationServiceGetApplicationRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.get_application(request)
puts "Application: #{response.app.name}"
Returns a list of applications matching the input parameters. Results can be filtered and sorted.Required permission: project.app.read
request = Zitadel::Client::ApplicationServiceListApplicationsRequest.new(
  project_id: 'project_123',
  queries: [{
    name_query: {
      name: 'Web',
      method: 'TEXT_QUERY_METHOD_CONTAINS'
    }
  }]
)

response = app_api.list_applications(request)
response.result.each do |app|
  puts "Application: #{app.name}"
end
Changes the configuration of an OIDC, API or SAML type application, as well as the application name.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceUpdateApplicationRequest.new(
  project_id: 'project_123',
  app_id: 'app_123',
  name: 'Updated Application Name'
)

response = app_api.update_application(request)
Deletes the application belonging to the input project.Required permission: project.app.delete
request = Zitadel::Client::ApplicationServiceDeleteApplicationRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.delete_application(request)

Application State

Deactivates the application belonging to the input project.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceDeactivateApplicationRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.deactivate_application(request)
Reactivates the application belonging to the input project.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceReactivateApplicationRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.reactivate_application(request)

Client Secrets

Generates the client secret of an API or OIDC application.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceGenerateClientSecretRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.generate_client_secret(request)
# Store the secret safely - it won't be retrievable again
puts "Client Secret: #{response.client_secret}"

Application Keys

Create a new application key, which is used to authorize an API application. Key details are returned in the response and must be stored safely.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceCreateApplicationKeyRequest.new(
  project_id: 'project_123',
  app_id: 'app_123',
  type: 'KEY_TYPE_JSON',
  expiration_date: Time.now + 365 * 24 * 3600 # 1 year
)

response = app_api.create_application_key(request)
# Store the key safely - it won't be retrievable again
puts "Key ID: #{response.key_id}"
puts "Key Details: #{response.key_details}"
Retrieves the application key matching the provided ID.Required permission: project.app.read
request = Zitadel::Client::ApplicationServiceGetApplicationKeyRequest.new(
  project_id: 'project_123',
  app_id: 'app_123',
  key_id: 'key_123'
)

response = app_api.get_application_key(request)
puts "Key Type: #{response.key.type}"
Returns a list of application keys matching the input parameters.Required permission: project.app.read
request = Zitadel::Client::ApplicationServiceListApplicationKeysRequest.new(
  project_id: 'project_123',
  app_id: 'app_123'
)

response = app_api.list_application_keys(request)
response.result.each do |key|
  puts "Key ID: #{key.id}, Type: #{key.type}"
end
Deletes an application key matching the provided ID.Required permission: project.app.write
request = Zitadel::Client::ApplicationServiceDeleteApplicationKeyRequest.new(
  project_id: 'project_123',
  app_id: 'app_123',
  key_id: 'key_123'
)

response = app_api.delete_application_key(request)

Example: Create OIDC Native Application

# Create a mobile/native OIDC application
request = Zitadel::Client::ApplicationServiceCreateApplicationRequest.new(
  project_id: 'project_123',
  name: 'My Mobile App',
  oidc_config: {
    redirect_uris: [
      'com.myapp://callback',
      'http://localhost:8080/callback'
    ],
    response_types: ['OIDC_RESPONSE_TYPE_CODE'],
    grant_types: [
      'OIDC_GRANT_TYPE_AUTHORIZATION_CODE',
      'OIDC_GRANT_TYPE_REFRESH_TOKEN'
    ],
    app_type: 'OIDC_APP_TYPE_NATIVE',
    auth_method_type: 'OIDC_AUTH_METHOD_TYPE_NONE', # PKCE
    version: 'OIDC_VERSION_1_0'
  }
)

response = app_api.create_application(request)

Example: Create API Application

# Create an API application with JWT authentication
request = Zitadel::Client::ApplicationServiceCreateApplicationRequest.new(
  project_id: 'project_123',
  name: 'My API',
  api_config: {
    auth_method_type: 'API_AUTH_METHOD_TYPE_PRIVATE_KEY_JWT'
  }
)

response = app_api.create_application(request)

# Create a key for the API application
key_request = Zitadel::Client::ApplicationServiceCreateApplicationKeyRequest.new(
  project_id: 'project_123',
  app_id: response.app_id,
  type: 'KEY_TYPE_JSON',
  expiration_date: Time.now + 365 * 24 * 3600
)

key_response = app_api.create_application_key(key_request)
puts "API Key: #{key_response.key_details}"

See Also

Build docs developers (and LLMs) love