Resolve a Contact and target Account, then update the Contact's AccountId.
Queries for the Contact and the target Account, then patches the Contact so its AccountId points at the resolved Account. Ends early if either lookup returns no record.
arazzo: 1.0.1
info:
title: Salesforce Sales Cloud Reparent Contact To Account
summary: Look up a Contact and a target Account by SOQL, then move the Contact under that Account.
description: >-
A relationship-repair pattern over the Query and SObject Rows resources. The
workflow queries for a Contact by email and for a target Account by name,
branches when either is missing, and when both resolve patches the Contact's
AccountId to reparent it under the target Account. Every step inlines its
request and the OAuth bearer Authorization header.
version: 1.0.0
sourceDescriptions:
- name: queryApi
url: ../openapi/salesforce-sales-cloud-query-api-openapi.yml
type: openapi
- name: sobjectRowsApi
url: ../openapi/salesforce-sales-cloud-sobject-rows-api-openapi.yml
type: openapi
workflows:
- workflowId: reparent-contact-to-account
summary: Resolve a Contact and target Account, then update the Contact's AccountId.
description: >-
Queries for the Contact and the target Account, then patches the Contact so
its AccountId points at the resolved Account. Ends early if either lookup
returns no record.
inputs:
type: object
required:
- accessToken
- contactEmail
- targetAccountName
properties:
accessToken:
type: string
description: OAuth 2.0 access token used as the Bearer credential.
contactEmail:
type: string
description: Email of the Contact to reparent.
targetAccountName:
type: string
description: Name of the Account to move the Contact under.
steps:
- stepId: findContact
description: Query for the Contact by email.
operationId: $sourceDescriptions.queryApi.executeSOQLQuery
parameters:
- name: Authorization
in: header
value: Bearer $inputs.accessToken
- name: q
in: query
value: "SELECT Id FROM Contact WHERE Email = '$inputs.contactEmail' LIMIT 1"
successCriteria:
- condition: $statusCode == 200
outputs:
totalSize: $response.body#/totalSize
contactId: $response.body#/records/0/Id
onSuccess:
- name: contactMissing
type: end
criteria:
- condition: $response.body#/totalSize == 0
- stepId: findAccount
description: Query for the target Account by name.
operationId: $sourceDescriptions.queryApi.executeSOQLQuery
parameters:
- name: Authorization
in: header
value: Bearer $inputs.accessToken
- name: q
in: query
value: "SELECT Id FROM Account WHERE Name = '$inputs.targetAccountName' LIMIT 1"
successCriteria:
- condition: $statusCode == 200
outputs:
totalSize: $response.body#/totalSize
accountId: $response.body#/records/0/Id
onSuccess:
- name: accountFound
type: goto
stepId: reparentContact
criteria:
- condition: $response.body#/totalSize > 0
- name: accountMissing
type: end
criteria:
- condition: $response.body#/totalSize == 0
- stepId: reparentContact
description: Patch the Contact's AccountId to the resolved target Account.
operationId: $sourceDescriptions.sobjectRowsApi.updateSObjectRecord
parameters:
- name: Authorization
in: header
value: Bearer $inputs.accessToken
- name: sObjectName
in: path
value: Contact
- name: recordId
in: path
value: $steps.findContact.outputs.contactId
requestBody:
contentType: application/json
payload:
AccountId: $steps.findAccount.outputs.accountId
successCriteria:
- condition: $statusCode == 204
outputs:
contactId: $steps.findContact.outputs.contactId
newAccountId: $steps.findAccount.outputs.accountId
Calls without X-API-Key need no key. Calls with it need a paid plan — get a key.
Get an API key
Free tier, no form to fill in. Signing in shares your email address with us — we
store it to create your key and to recognise you if you sign in with another
provider. By signing up you are subscribing to the APIs.io and API Evangelist
newsletters — you can unsubscribe from any issue. See our
Privacy Policy and Terms.