Skip to content

Conversation

@swaroopAkkineniWorkos
Copy link
Contributor

@swaroopAkkineniWorkos swaroopAkkineniWorkos commented Feb 10, 2026

linear: https://linear.app/workos/issue/ENT-4372/sdk-updates

I decided to break up the work for ENT-4372 into a smaller pr's that we can be easily reviewed and merge them into ENT-4372-base-authorization-branch. Then we can have one final merge that merges ENT-4372-base-authorization-branch into the main.

desc: the goal of this pr is to implement the following endpoints in the node sdk.

listResources()               | GET /authorization/organizations/{org_id}/resources

getResourceByExternalId()     | GET /authorization/organizations/{org_id}/resources/{type}/{external_id}
updateResourceByExternalId()  | PATCH /authorization/organizations/{org_id}/resources/{type}/{external_id}
deleteResourceByExternalId()  | DELETE /authorization/organizations/{org_id}/resources/{type}/{external_id}

Each one will call the corresponding new fga endpoints within workos repo

listResources() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources.controller.ts#L83

getResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L90
updateResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L183
deleteResourceByExternalId() ~ https://github.com/workos/workos/blob/51f5a445c3a247f5f093bfaae8e385629df56d36/packages/api/src/authorization-resources/authorization-resources-by-external-id.controller.ts#L221

@linear
Copy link

linear bot commented Feb 10, 2026

ENT-4372 SDK Updates

@swaroopAkkineniWorkos swaroopAkkineniWorkos changed the title lol Authorization Resources (external ID) endpoints and listResources endpoint Feb 10, 2026
@swaroopAkkineniWorkos
Copy link
Contributor Author

@greptile can you plz do a first pass review

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

11 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Co-authored-by: Cursor <cursoragent@cursor.com>
@swaroopAkkineniWorkos
Copy link
Contributor Author

@greptile plz re-review this pr

@workos workos deleted a comment from greptile-apps bot Feb 10, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@workos workos deleted a comment from greptile-apps bot Feb 10, 2026
@workos workos deleted a comment from greptile-apps bot Feb 10, 2026
@swaroopAkkineniWorkos
Copy link
Contributor Author

@greptile plz re-review this pr

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 10, 2026

Greptile Overview

Greptile Summary

This PR implements four new authorization resource endpoints that enable operations using external IDs instead of internal resource IDs:

  • listResources() - Retrieves paginated list of resources with filtering by organization, resource type, parent resource, and search
  • getResourceByExternalId() - Fetches a specific resource by organization ID, resource type slug, and external ID
  • updateResourceByExternalId() - Updates resource name and/or description using external ID
  • deleteResourceByExternalId() - Deletes a resource using external ID

The implementation follows established patterns in the codebase with consistent serialization, proper TypeScript typing, and comprehensive test coverage. All new methods properly handle nullable fields (description, parent_resource_id) and use the existing deserialization utilities. The list endpoint includes pagination support with before/after cursors and array filters are correctly serialized as comma-separated strings.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • The implementation follows existing patterns consistently, includes comprehensive test coverage with edge cases (null values, empty bodies, pagination), uses proper TypeScript types, and correctly handles serialization/deserialization. No security concerns, no breaking changes, and all custom rules are satisfied.
  • No files require special attention

Important Files Changed

Filename Overview
src/authorization/authorization.ts Added four new resource endpoints using external ID: listResources(), getResourceByExternalId(), updateResourceByExternalId(), and deleteResourceByExternalId() with consistent API patterns
src/authorization/authorization.spec.ts Comprehensive test coverage for all new endpoints including edge cases, pagination, filters, and null handling
src/authorization/serializers/list-authorization-resources-options.serializer.ts Serializer properly converts camelCase options to snake_case parameters and joins arrays into comma-separated strings
src/authorization/serializers/update-authorization-resource-by-external-id-options.serializer.ts Serializer correctly handles optional name and description fields using !== undefined checks to allow null values
src/authorization/interfaces/list-authorization-resources-options.interface.ts Interface properly extends PaginationOptions and defines array filters with corresponding snake_case serialized version

Sequence Diagram

sequenceDiagram
    participant Client
    participant SDK as WorkOS SDK
    participant Serializer
    participant API as WorkOS API

    Note over Client,API: List Resources Flow
    Client->>SDK: listResources(options)
    SDK->>Serializer: serializeListAuthorizationResourcesOptions()
    Serializer->>Serializer: Convert arrays to comma-separated strings
    Serializer->>Serializer: Convert camelCase to snake_case
    Serializer-->>SDK: serialized params
    SDK->>API: GET /authorization/resources?params
    API-->>SDK: AuthorizationResourceListResponse
    SDK->>SDK: deserializeAuthorizationResource() for each item
    SDK-->>Client: AuthorizationResourceList

    Note over Client,API: Get/Update/Delete by External ID Flow
    Client->>SDK: getResourceByExternalId({org, type, externalId})
    SDK->>API: GET /authorization/organizations/{org}/resources/{type}/{externalId}
    API-->>SDK: AuthorizationResourceResponse
    SDK->>SDK: deserializeAuthorizationResource()
    SDK-->>Client: AuthorizationResource

    Client->>SDK: updateResourceByExternalId(options)
    SDK->>Serializer: serializeUpdateResourceByExternalIdOptions()
    Serializer->>Serializer: Filter undefined fields
    Serializer-->>SDK: serialized body
    SDK->>API: PATCH /authorization/organizations/{org}/resources/{type}/{externalId}
    API-->>SDK: AuthorizationResourceResponse
    SDK->>SDK: deserializeAuthorizationResource()
    SDK-->>Client: AuthorizationResource

    Client->>SDK: deleteResourceByExternalId({org, type, externalId})
    SDK->>API: DELETE /authorization/organizations/{org}/resources/{type}/{externalId}
    API-->>SDK: 204 No Content
    SDK-->>Client: void
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

@swaroopAkkineniWorkos swaroopAkkineniWorkos marked this pull request as ready for review February 11, 2026 13:51
@swaroopAkkineniWorkos swaroopAkkineniWorkos requested a review from a team as a code owner February 11, 2026 13:51
@swaroopAkkineniWorkos swaroopAkkineniWorkos requested review from atainter, csrbarber, mattgd and nicknisi and removed request for a team February 11, 2026 13:51
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

12 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

await this.workos.delete(`/authorization/resources/${resourceId}`);
}

// part 2
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// part 2

): Promise<AuthorizationResource> {
const { organizationId, resourceTypeSlug, externalId } = options;
const { data } = await this.workos.get<AuthorizationResourceResponse>(
`/authorization/organizations/${organizationId}/resources/${resourceTypeSlug}/${externalId}`,
Copy link
Member

Choose a reason for hiding this comment

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

suggestion: could externalId contain URL-significant characters? Not sure if this is gated elsewhere but could be good to wrap with encodeURIComponent.

Base automatically changed from ENT-4372-Internal-ID to ENT-4372-base-authorization-branch February 11, 2026 19:12
}

export interface SerializedListAuthorizationResourcesOptions {
organization_ids?: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

I have a ticket to change this and slugs to singular organization_id, resource_type_slug

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll update with a change once it is merged

@@ -31,8 +31,6 @@ export interface CreateAuthorizationResourceOptions {
resourceTypeSlug: string;
organizationId: string;
parentResourceId?: string | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about type_slug + external_id

@swaroopAkkineniWorkos swaroopAkkineniWorkos merged commit 4be4df5 into ENT-4372-base-authorization-branch Feb 12, 2026
8 checks passed
@swaroopAkkineniWorkos swaroopAkkineniWorkos deleted the ENT-4372-resources-external branch February 12, 2026 00:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants