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 getObjectByExternalId
method allows you to retrieve a specific object from the Teamwork Graph
using its external ID and object type. This is useful for fetching individual entities when you know
their external identifier.
1 2getObjectByExternalId(request: GetObjectByExternalIdRequest): Promise<GetObjectByExternalIdResponse>
GetObjectByExternalIdRequest
1 2{ objectType: string; // objectType: The type of object to retrieve (e.g., 'atlassian:document', 'atlassian:message') externalId: string; // externalId: The external identifier of the object }
1 2import { graph } from '@forge/teamwork-graph'; const request = { objectType: 'atlassian:document', externalId: 'pipelines/123/builds/456' }; const response = await graph.getObjectByExternalId(request); if (response.success) { console.log('Object found:', response.object); } else { console.error('Error retrieving object:', response.error); } /
1 2// Retrieve a document object const documentRequest = { objectType: 'atlassian:document', externalId: 'api-doc-456' }; const documentResponse = await graph.getObjectByExternalId(documentRequest); // Retrieve a message object const messageRequest = { objectType: 'atlassian:message', externalId: 'msg-789' }; const messageResponse = await graph.getObjectByExternalId(messageRequest);
Only one externalId
per request.
The method validates the following:
objectType
field must be a non-empty string.externalId
field must be a non-empty string.externalId
.Error message | Description |
---|---|
objectType is required | The objectType is missing or empty. |
externalId is required | The externalId is missing or empty. |
Object not found | The specified object doesn't exist (API response). |
Failed to get object by external ID | The API request failed. |
The method returns a promise that resolves to a GetObjectByExternalIdResponse
object.
1 2{ success: boolean; // Indicates if the operation was successful object?: Object; // The retrieved object (if found) error?: string; // 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 request creation const request: types.GetObjectByExternalIdRequest = { objectType: 'atlassian:document', externalId: 'pipelines/123/builds/456' }; // Type-safe response handling const response = await graph.getObjectByExternalId(request); if (response.success && response.object) { // TypeScript knows object exists here const object = response.object; // Access object properties safely with proper typing // The object is typed as the union of all possible object types // TypeScript will enforce the correct structure based on the object type if ('atlassian:document' in object) { // TypeScript knows this is a DocumentObject const document = object['atlassian:document']; console.log('Document ID:', document.id); console.log('Document Type:', document.type); } else if ('atlassian:message' in object) { // TypeScript knows this is a MessageObject const message = object['atlassian:message']; console.log('Message ID:', message.id); console.log('Message Content:', message.content); } }
The type system ensures:
request.objectType
and request.externalId
must be stringsresponse.object
is properly typed as Object
(union of all object types) when success
is trueObject
union type includes all supported object types like DocumentObject
, MessageObject
, BranchObject
, etc.in
operator and access type-specific propertiesRate this page: