The deleteRelationship method allows you to delete a specific relationship between entities in the Teamwork Graph.
1 2deleteRelationship(request: DeleteRelationshipRequest): Promise<DeleteRelationshipResponse>
DeleteRelationshipRequestDeleteRelationshipRequest1 2{ from: RelationshipEntity; // Required - Source entity to: RelationshipEntity; // Required - Target entity type: string; // Required - Relationship type updateSequenceNumber: number; // Required - Must be >= 0 connectionId: string; // Required - Connection identifier }
DeleteRelationshipResponse1 2{ success: boolean; error?: string; originalError?: unknown; }
from, to, type, updateSequenceNumber, connectionIdfrom.type, from.value, to.type, to.value) are required1 2import { graph, types } from '@forge/teamwork-graph'; const response = await graph.deleteRelationship({ from: { type: 'atlassian:team', value: { entityId: 'team-id-1' } }, to: { type: 'issueWorklogId', value: { issueId: '10001', worklogId: '20002' } }, type: 'external-team-works-on-worklog', updateSequenceNumber: 1, connectionId: 'your-connection-id' }); if (response.success) { console.log('Relationship deleted successfully'); // Response: { success: true } } else { console.error('Error:', response.error); }
1 2import { graph, types } from '@forge/teamwork-graph'; async function deleteRelationship(connectionId: string) { try { const response = await graph.deleteRelationship({ from: { type: 'atlassian:team', value: { entityId: 'team-id-1' } }, to: { type: 'issueWorklogId', value: { issueId: 'PT-1', worklogId: '10000' } }, type: 'external-team-works-on-worklog', updateSequenceNumber: 1, connectionId: connectionId }); if (response.success) { console.log('Relationship deleted successfully'); // response = { success: true } return response; } else { console.error('Failed to delete relationship:', response.error); throw new Error(response.error); } } catch (error) { console.error('Error deleting relationship:', error); throw error; } }
The method validates the following:
from, to, type, updateSequenceNumber, connectionId must all be providedfrom.type, from.value, to.type, to.value must all be provided| Error message | Description |
|---|---|
{field} is required | A required field is missing from the request. |
updateSequenceNumber must be a non-negative number | The updateSequenceNumber is negative or invalid. |
Failed to delete relationship: Bad Request - {details} | The API request failed with a bad request error. |
The method returns a promise that resolves to a DeleteRelationshipResponse object.
On successful deletion, the API returns HTTP status 202 Accepted and the response contains:
1 2{ "success": true }
Example:
1 2const response = await graph.deleteRelationship({ from: { type: 'atlassian:team', value: { entityId: 'team-id-1' } }, to: { type: 'issueWorklogId', value: { issueId: '10001', worklogId: '20002' } }, type: 'external-team-works-on-worklog', updateSequenceNumber: 1, connectionId: 'your-connection-id' }); // response = { success: true }
1 2{ "success": false, "error": "Failed to delete relationship: Bad Request - {details}", "originalError": { "code": "API_ERROR", "details": { "status": 400, "responseBody": { /* error details */ } } } }
All types are exported from @forge/teamwork-graph:
1 2import { types, graph } from '@forge/teamwork-graph'; // Available types: // - types.DeleteRelationshipRequest // - types.DeleteRelationshipResponse // - types.RelationshipEntity // - types.RelationshipEntityValue
updateSequenceNumber when deleting relationships to ensure proper conflict resolutionsuccess field and handle errors appropriatelyconnectionId for your connectorfrom and to entities exactly match the relationship you want to deleteRate this page: