> ## Documentation Index
> Fetch the complete documentation index at: https://stytch.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# External IDs

> Assign and use external IDs for Stytch resources in place of Stytch-assigned UUIDs.

> [tab] Consumer auth
>
> When a User (Represents an end user's account in your application.) is created in Stytch, they will be assigned a unique identifier that looks like a UUID. For your convenience, you may choose to additionally assign an "external ID" to a user which can then be used in any place where the Stytch `user_id` is expected.
>
> ## Assigning an external ID at creation
>
> When calling the [Create User](https://stytch.com/docs/api-reference/consumer/api/users/create-user.md) endpoint, you may pass in an optional `external_id` parameter. The `external_id` is a string consisting of alphanumeric, ., `_`, or `-` characters with a maximum length of 128 characters. External IDs must be unique across users in your project.
>
> You may also set an external ID during a call to the [Migrate Password](https://stytch.com/docs/api-reference/consumer/api/passwords/migrate.md) endpoint, but only if the user does not yet exist and is created. If the user already exists, you must use the [Update User](https://stytch.com/docs/api-reference/consumer/api/users/update-user.md) endpoint to assign or reassign the `external_id`.
>
> ## Assigning an external ID later
>
> If a user has already been created, you may assign it an `external_id` *later* with the [Update User](https://stytch.com/docs/api-reference/consumer/api/users/update-user.md) endpoint. Similar to creation, pass in an `external_id` parameter and it will then be assigned to that user. Again, remember that external IDs must be unique within your project.
>
> ## Updating a user's external ID
>
> If you wish to change a user's external ID, you may use the same [Update User](https://stytch.com/docs/api-reference/consumer/api/users/update-user.md) endpoint listed above. After this point, you will no longer be able to refer to that user by its *old* `external_id`.
>
> ## Using external IDs
>
> In any endpoint that expects a `user_id`, you may instead choose to pass in your custom-defined `external_id`. For clarity, all responses *from* Stytch will continue to use the Stytch-defined `user_id`, though `external_id` will exist as a subfield within the User object.

> [tab] B2B auth
>
> When a Member (Represents an individual end user's account within a given Organization, uniquely identified within that Organization by their email address.) or Organization (Represents an instance or tenant in your application, typically mapping to each of your top-level customers.) is created in Stytch, they will be assigned a unique identifier that looks like a UUID.
> For your convenience, you may choose to additionally assign an "external ID" to a member which can then be used in any place where the Stytch `member_id` is expected.
> You can also assign an "organization external ID" to an organization which can then be used any place where the Stytch `organization_id` is expected.
>
> ## Assigning an external ID at creation
>
> An External IDs is a string consisting of alphanumeric, `.`, `_`, or `-` characters with a maximum length of 128 characters.
> Member external IDs must be unique across members in a given organization, but may be reused across different organizations in the same project.
> Organization external IDs must be unique across all organizations in the same project
>
> When calling the [Create Member](https://stytch.com/docs/api-reference/b2b/api/members/create-member.md) you may pass in an optional `external_id` parameter.
> When calling the [Create Organization](https://stytch.com/docs/api-reference/b2b/api/organizations/create-organization.md) you may pass in an optional `organization_external_id` parameter.
>
> You may also set an external ID during a call to the [Migrate Password](https://stytch.com/docs/api-reference/b2b/api/passwords/migrate.md) endpoint, but only if the member does not yet exist and is created.
> If the member already exists, you must use the [Update Member](https://stytch.com/docs/api-reference/b2b/api/members/update-member.md) endpoint to assign or reassign the `external_id`.
>
> ## Assigning an external ID later
>
> If a member has already been created, you may assign it an `external_id` *later* with the [Update Member](https://stytch.com/docs/api-reference/b2b/api/members/update-member.md) endpoint.
> Similar to creation, pass in an `external_id` parameter and it will then be assigned to that member.
> Again, remember that external IDs must be unique within a given organization, but may be reused across different organizations in the same project.
>
> Organizations can similarly be assigned an `organization_external_id` later with the [Update Organization](https://stytch.com/docs/api-reference/b2b/api/organizations/update-organization.md) endpoint.
>
> ## Updating external IDs
>
> If you wish to change a member's external ID you may use the same [Update Member](https://stytch.com/docs/api-reference/b2b/api/members/update-member.md) endpoints listed above.
>
> If you wish to change an organization's external ID you may use the [Update Organization](https://stytch.com/docs/api-reference/b2b/api/organizations/update-organization.md) endpoint.
>
> After this point, you will no longer be able to refer to that entity by its *old* `external_id`.
>
> ## Using external IDs
>
> In any endpoint that expects a `member_id`, you may instead choose to pass in your custom-defined `external_id`.
> For clarity, all responses *from* Stytch will continue to use the Stytch-defined `member_id`, though `external_id` will exist as a subfield within the Member object.
>
> In any endpoint that expects an `organization_id`, you may instead choose to pass in your custom-defined `organization_external_id`.
> Similarly, all responses *from* Stytch will continue to use the Stytch-defined `organization_id`, though `organization_external_id` will exist as a subfield within the Organization object.
>
> ```js theme={null}
> const stytch = require('stytch');
>
> const client = new stytch.B2BClient({
>   project_id: '${projectId}',
>   secret: '${secret}',
> });
>
> const params = {
>   organization_id: "example-organization-external-id",
>   member_id: "example-member-external-id",
> };
>
> client.organizations.members.get(params)
>   .then(resp => { console.log(resp) })
>   .catch(err => { console.log(err) });
> ```
