Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .last-synced-sha
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92db0495807c86fbbc4d45bd266a6c1f5bcbb59c
ff939ff075453287993e1e6182f1d6f23c67ab80
58 changes: 45 additions & 13 deletions .oagen-manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"version": 2,
"language": "ruby",
"generatedAt": "2026-04-30T17:41:02.756Z",
"generatedAt": "2026-05-03T22:57:55.027Z",
"files": [
"lib/workos.rb",
"lib/workos/admin_portal.rb",
Expand All @@ -20,9 +20,11 @@
"lib/workos/api_keys/api_key_revoked_data.rb",
"lib/workos/api_keys/api_key_revoked_data_owner.rb",
"lib/workos/api_keys/api_key_validation_response.rb",
"lib/workos/api_keys/api_key_with_value.rb",
"lib/workos/api_keys/api_key_with_value_owner.rb",
"lib/workos/api_keys/create_organization_api_key.rb",
"lib/workos/api_keys/organization_api_key.rb",
"lib/workos/api_keys/organization_api_key_owner.rb",
"lib/workos/api_keys/organization_api_key_with_value.rb",
"lib/workos/api_keys/organization_api_key_with_value_owner.rb",
"lib/workos/api_keys/validate_api_key.rb",
"lib/workos/audit_logs.rb",
"lib/workos/audit_logs/audit_log_action_json.rb",
Expand Down Expand Up @@ -283,6 +285,7 @@
"lib/workos/sso/sso_token_response.rb",
"lib/workos/sso/sso_token_response_oauth_token.rb",
"lib/workos/sso/token_query.rb",
"lib/workos/types/api_keys_order.rb",
"lib/workos/types/applications_order.rb",
"lib/workos/types/audit_log_configuration_log_stream_state.rb",
"lib/workos/types/audit_log_configuration_log_stream_type.rb",
Expand Down Expand Up @@ -412,6 +415,7 @@
"lib/workos/types/user_organization_membership_status.rb",
"lib/workos/types/user_sessions_auth_method.rb",
"lib/workos/types/user_sessions_status.rb",
"lib/workos/types/vault_byok_key_deleted_data_key_provider.rb",
"lib/workos/types/vault_byok_key_verification_completed_data_key_provider.rb",
"lib/workos/types/vault_data_created_data_actor_source.rb",
"lib/workos/types/vault_data_deleted_data_actor_source.rb",
Expand Down Expand Up @@ -490,6 +494,7 @@
"lib/workos/user_management/create_password_reset_token.rb",
"lib/workos/user_management/create_redirect_uri.rb",
"lib/workos/user_management/create_user.rb",
"lib/workos/user_management/create_user_api_key.rb",
"lib/workos/user_management/create_user_invite_options.rb",
"lib/workos/user_management/create_user_organization_membership.rb",
"lib/workos/user_management/device_authorization_response.rb",
Expand Down Expand Up @@ -544,6 +549,10 @@
"lib/workos/user_management/update_user.rb",
"lib/workos/user_management/update_user_organization_membership.rb",
"lib/workos/user_management/user.rb",
"lib/workos/user_management/user_api_key.rb",
"lib/workos/user_management/user_api_key_owner.rb",
"lib/workos/user_management/user_api_key_with_value.rb",
"lib/workos/user_management/user_api_key_with_value_owner.rb",
"lib/workos/user_management/user_created.rb",
"lib/workos/user_management/user_deleted.rb",
"lib/workos/user_management/user_identities_get_item.rb",
Expand All @@ -555,6 +564,8 @@
"lib/workos/user_management/verify_email_address.rb",
"lib/workos/user_management/verify_email_response.rb",
"lib/workos/user_management_organization_membership_groups.rb",
"lib/workos/vault/vault_byok_key_deleted.rb",
"lib/workos/vault/vault_byok_key_deleted_data.rb",
"lib/workos/vault/vault_byok_key_verification_completed.rb",
"lib/workos/vault/vault_byok_key_verification_completed_data.rb",
"lib/workos/vault/vault_data_created.rb",
Expand Down Expand Up @@ -597,8 +608,6 @@
"rbi/workos/api_key_revoked_data.rbi",
"rbi/workos/api_key_revoked_data_owner.rbi",
"rbi/workos/api_key_validation_response.rbi",
"rbi/workos/api_key_with_value.rbi",
"rbi/workos/api_key_with_value_owner.rbi",
"rbi/workos/api_keys.rbi",
"rbi/workos/application_credentials_list_item.rbi",
"rbi/workos/assign_role.rbi",
Expand Down Expand Up @@ -730,6 +739,7 @@
"rbi/workos/create_redirect_uri.rbi",
"rbi/workos/create_role.rbi",
"rbi/workos/create_user.rbi",
"rbi/workos/create_user_api_key.rbi",
"rbi/workos/create_user_invite_options.rbi",
"rbi/workos/create_user_organization_membership.rbi",
"rbi/workos/create_webhook_endpoint.rbi",
Expand Down Expand Up @@ -856,6 +866,10 @@
"rbi/workos/multi_factor_auth.rbi",
"rbi/workos/new_connect_application_secret.rbi",
"rbi/workos/organization.rbi",
"rbi/workos/organization_api_key.rbi",
"rbi/workos/organization_api_key_owner.rbi",
"rbi/workos/organization_api_key_with_value.rbi",
"rbi/workos/organization_api_key_with_value_owner.rbi",
"rbi/workos/organization_created.rbi",
"rbi/workos/organization_created_data.rbi",
"rbi/workos/organization_created_data_domain.rbi",
Expand Down Expand Up @@ -968,6 +982,10 @@
"rbi/workos/update_user_organization_membership.rbi",
"rbi/workos/update_webhook_endpoint.rbi",
"rbi/workos/user.rbi",
"rbi/workos/user_api_key.rbi",
"rbi/workos/user_api_key_owner.rbi",
"rbi/workos/user_api_key_with_value.rbi",
"rbi/workos/user_api_key_with_value_owner.rbi",
"rbi/workos/user_authentication_factor_enroll_response.rbi",
"rbi/workos/user_consent_option.rbi",
"rbi/workos/user_consent_option_choice.rbi",
Expand All @@ -985,6 +1003,8 @@
"rbi/workos/user_sessions_list_item.rbi",
"rbi/workos/user_updated.rbi",
"rbi/workos/validate_api_key.rbi",
"rbi/workos/vault_byok_key_deleted.rbi",
"rbi/workos/vault_byok_key_deleted_data.rbi",
"rbi/workos/vault_byok_key_verification_completed.rbi",
"rbi/workos/vault_byok_key_verification_completed_data.rbi",
"rbi/workos/vault_data_created.rbi",
Expand Down Expand Up @@ -1038,14 +1058,6 @@
"test/workos/test_widgets.rb"
],
"operations": {
"POST /api_keys/validations": {
"sdkMethod": "create_validation",
"service": "api_keys"
},
"DELETE /api_keys/{id}": {
"sdkMethod": "delete_api_key",
"service": "api_keys"
},
"POST /auth/challenges/{id}/verify": {
"sdkMethod": "verify_challenge",
"service": "multi_factor_auth"
Expand Down Expand Up @@ -1622,6 +1634,10 @@
"sdkMethod": "revoke_invitation",
"service": "user_management"
},
"GET /user_management/jwt_template": {
"sdkMethod": "list_jwt_template",
"service": "user_management"
},
"PUT /user_management/jwt_template": {
"sdkMethod": "update_jwt_template",
"service": "user_management"
Expand Down Expand Up @@ -1722,6 +1738,22 @@
"sdkMethod": "create_token",
"service": "widgets"
},
"POST /api_keys/validations": {
"sdkMethod": "create_validation",
"service": "api_keys"
},
"DELETE /api_keys/{id}": {
"sdkMethod": "delete_api_key",
"service": "api_keys"
},
"GET /user_management/users/{userId}/api_keys": {
"sdkMethod": "list_user_api_keys",
"service": "user_management"
},
"POST /user_management/users/{userId}/api_keys": {
"sdkMethod": "create_user_api_key",
"service": "user_management"
},
"GET /audit_logs/actions": {
"sdkMethod": "list_actions",
"service": "audit_logs"
Expand Down
88 changes: 44 additions & 44 deletions lib/workos/api_keys.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,54 +10,14 @@ def initialize(client)
@client = client
end

# Validate API key
# @param value [String] The value for an API key.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [WorkOS::ApiKeyValidationResponse]
def create_validation(
value:,
request_options: {}
)
body = {
"value" => value
}
response = @client.request(
method: :post,
path: "/api_keys/validations",
auth: true,
body: body,
request_options: request_options
)
result = WorkOS::ApiKeyValidationResponse.new(response.body)
result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
result
end

# Delete an API key
# @param id [String] The unique ID of the API key.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [void]
def delete_api_key(
id:,
request_options: {}
)
@client.request(
method: :delete,
path: "/api_keys/#{WorkOS::Util.encode_path(id)}",
auth: true,
request_options: request_options
)
nil
end

# List API keys for an organization
# @param organization_id [String] Unique identifier of the Organization.
# @param before [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.
# @param after [String, nil] An object ID that defines your place in the list. When the ID is not present, you are at the end of the list.
# @param limit [Integer, nil] Upper limit on the number of objects to return, between `1` and `100`.
# @param order [WorkOS::Types::OrganizationsApiKeysOrder, nil] Order the results by the creation time.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [WorkOS::Types::ListStruct<WorkOS::ApiKey>]
# @return [WorkOS::Types::ListStruct<WorkOS::OrganizationApiKey>]
def list_organization_api_keys(
organization_id:,
before: nil,
Expand Down Expand Up @@ -91,7 +51,7 @@ def list_organization_api_keys(
}
WorkOS::Types::ListStruct.from_response(
response,
model: WorkOS::ApiKey,
model: WorkOS::OrganizationApiKey,
filters: {organization_id: organization_id, before: before, limit: limit, order: order},
fetch_next: fetch_next
)
Expand All @@ -102,7 +62,7 @@ def list_organization_api_keys(
# @param name [String] The name for the API key.
# @param permissions [Array<String>, nil] The permission slugs to assign to the API key.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [WorkOS::ApiKeyWithValue]
# @return [WorkOS::OrganizationApiKeyWithValue]
def create_organization_api_key(
organization_id:,
name:,
Expand All @@ -120,9 +80,49 @@ def create_organization_api_key(
body: body,
request_options: request_options
)
result = WorkOS::ApiKeyWithValue.new(response.body)
result = WorkOS::OrganizationApiKeyWithValue.new(response.body)
result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
result
end

# Validate API key
# @param value [String] The value for an API key.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [WorkOS::ApiKeyValidationResponse]
def create_validation(
value:,
request_options: {}
)
body = {
"value" => value
}
response = @client.request(
method: :post,
path: "/api_keys/validations",
auth: true,
body: body,
request_options: request_options
)
result = WorkOS::ApiKeyValidationResponse.new(response.body)
result.last_response = WorkOS::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
result
end

# Delete an API key
# @param id [String] The unique ID of the API key.
# @param request_options [Hash] (see WorkOS::Types::RequestOptions)
# @return [void]
def delete_api_key(
id:,
request_options: {}
)
@client.request(
method: :delete,
path: "/api_keys/#{WorkOS::Util.encode_path(id)}",
auth: true,
request_options: request_options
)
nil
end
end
end
2 changes: 1 addition & 1 deletion lib/workos/api_keys/api_key.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(json)
hash = self.class.normalize(json)
@object = hash[:object]
@id = hash[:id]
@owner = hash[:owner] ? WorkOS::ApiKeyOwner.new(hash[:owner]) : nil
@owner = hash[:owner]
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 owner now returns a raw Hash, breaking the typed accessor contract

Previously @owner was deserialized as WorkOS::ApiKeyOwner.new(...), giving callers a typed object with named accessors (e.g. api_key.owner.type). After this change it returns the raw normalized Hash, so api_key.owner[:type] is now required. Any existing caller code that calls methods on owner will raise NoMethodError at runtime. The same regression is present in ApiKeyCreatedData (used in webhook events). The new OrganizationApiKey / OrganizationApiKeyWithValue correctly keep typed owner objects, making ApiKey and ApiKeyCreatedData inconsistent with the rest of the family.

@name = hash[:name]
@obfuscated_value = hash[:obfuscated_value]
@last_used_at = hash[:last_used_at]
Expand Down
2 changes: 1 addition & 1 deletion lib/workos/api_keys/api_key_created_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def initialize(json)
hash = self.class.normalize(json)
@object = hash[:object]
@id = hash[:id]
@owner = hash[:owner] ? WorkOS::ApiKeyCreatedDataOwner.new(hash[:owner]) : nil
@owner = hash[:owner]
@name = hash[:name]
@obfuscated_value = hash[:obfuscated_value]
@last_used_at = hash[:last_used_at]
Expand Down
43 changes: 43 additions & 0 deletions lib/workos/api_keys/organization_api_key.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

module WorkOS
class OrganizationApiKey < WorkOS::Types::BaseModel
HASH_ATTRS = {
object: :object,
id: :id,
owner: :owner,
name: :name,
obfuscated_value: :obfuscated_value,
last_used_at: :last_used_at,
permissions: :permissions,
created_at: :created_at,
updated_at: :updated_at
}.freeze

attr_accessor \
:object,
:id,
:owner,
:name,
:obfuscated_value,
:last_used_at,
:permissions,
:created_at,
:updated_at

def initialize(json)
hash = self.class.normalize(json)
@object = hash[:object]
@id = hash[:id]
@owner = hash[:owner] ? WorkOS::OrganizationApiKeyOwner.new(hash[:owner]) : nil
@name = hash[:name]
@obfuscated_value = hash[:obfuscated_value]
@last_used_at = hash[:last_used_at]
@permissions = hash[:permissions] || []
@created_at = hash[:created_at]
@updated_at = hash[:updated_at]
end
end
end
7 changes: 7 additions & 0 deletions lib/workos/api_keys/organization_api_key_owner.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# frozen_string_literal: true

# This file is auto-generated by oagen. Do not edit.

module WorkOS
OrganizationApiKeyOwner = ApiKeyCreatedDataOwner
end
Loading
Loading