The Connector SDK APIs are available through Forge's Early Access Program (EAP).
EAPs are offered to selected users for testing and feedback purposes. APIs and features under EAP are unsupported and subject to change without notice. APIs and features under EAP are not recommended for use in production environments.
To use the Connector SDK, you must be part of the Forge connector EAP. You can express interest in joining this EAP through this form.
The mapUsers
method allows you to create mappings between external users and Atlassian account IDs
or email addresses. This is essential for linking users from external systems to Atlassian accounts
for proper permissions and collaboration.
1 2mapUsers(request: MapUsersRequest): Promise<MapUsersResponse>
MapUsersRequest
1 2// MapUsersRequest object: { directMappings: UserMapping[]; // directMappings: Array of user mappings (maximum 100 mappings per request) }
Each mapping must contain either an accountId
or email
:
1 2type UserMapping = { externalId: string; // Required: External identifier for the user updateSequenceNumber: number; // Required: Sequence number for tracking updates updatedAt: number; // Required: Timestamp of the update accountId?: string; // Optional: Atlassian account ID (must have either this or email) email?: string; // Optional: External email address (must have either this or accountId) };
1 2import { graph } from '@forge/teamwork-graph'; const mappingWithAccountId = { externalId: 'user-123', accountId: '5dd4fb8db3a9c80fc0a3283b', updateSequenceNumber: 1, updatedAt: Date.now() }; const request = { directMappings: [mappingWithAccountId] }; const response = await graph.mapUsers(request);
1 2const mappingWithEmail = { externalId: 'user-456', email: 'user@my-company.com', updateSequenceNumber: 2, updatedAt: Date.now() }; const response = await graph.mapUsers({ directMappings: [mappingWithEmail] });
1 2const mappings = [ { externalId: 'user-123', accountId: '5dd4fb8db3a9c80fc0a3283b', updateSequenceNumber: 1, updatedAt: Date.now() }, { externalId: 'user-456', email: 'user@my-company.com', updateSequenceNumber: 2, updatedAt: Date.now() } ]; const response = await graph.mapUsers({ directMappings: mappings });
1 2const response = await graph.mapUsers({ directMappings: mappings }); if (response.success && response.results) { response.results.forEach(result => { if (result.success) { console.log(`Successfully mapped user ${result.externalId} to account ${result.accountId}`); } else { console.error(`Failed to map user ${result.externalId}: ${result.error}`); } }); }
The method validates the following:
directMappings
field must be a valid array.directMappings
array cannot be empty.externalId
.Error message | Description |
---|---|
directMappings must be an array | The directMappings field is not an array. |
directMappings array cannot be empty | The directMappings array is empty. |
Bulk user mapping supports maximum 100 mappings. Received X | The number of mappings per request has exceeded the maximum limit. |
Each mapping must have an externalId | The mapping is missing externalId . |
Each mapping must have either accountId or email | The mapping has neither identifier. |
The method returns a promise that resolves to a MapUsersResponse
object.
1 2// MapUsersResponse { success: boolean; // Indicates if the overall operation was successful results?: Array<{ // Individual results for each mapping externalId: string; // The external ID that was processed accountId?: string; // The mapped Atlassian account ID (if successful) success: boolean; // Whether this specific mapping was successful error?: string; // Error message for this specific mapping (if failed) }>; error?: string; // Overall error message (if operation failed) originalError?: unknown; // Original error object (if available) }
The SDK provides type-safe request and response objects that ensure compile-time validation:
1 2import { types } from '@forge/teamwork-graph'; // Type-safe mapping creation const mapping: types.UserMapping = { externalId: 'user-123', accountId: '5dd4fb8db3a9c80fc0a3283b', updateSequenceNumber: 1, updatedAt: Date.now() }; // Type-safe request creation const request: types.MapUsersRequest = { directMappings: [mapping] }; // Type-safe response handling const response = await graph.mapUsers(request); if (response.success && response.results) { // TypeScript knows results exists here and provides proper typing response.results.forEach(result => { // result is properly typed with externalId, accountId, success, and error properties if (result.success) { console.log(`Successfully mapped user: ${result.externalId}`); } else { console.error(`Failed to map user: ${result.externalId}, Error: ${result.error}`); } }); }
The type system ensures:
mapping
object has correct structure with required and optional propertiesrequest.directMappings
must be an array of UserMapping
objectsresponse.results
is properly typed when success
is trueRate this page: