Skip to content

Commit 5c2dc94

Browse files
committed
fix(apollo): send sequence add contact_ids/label_names as query params per docs
Apollo documents every field for emailer_campaigns/:id/add_contact_ids as a query parameter with no request body. Append contact_ids[]/label_names[] to the query string instead of the JSON body to match the documented contract.
1 parent 821bea1 commit 5c2dc94

1 file changed

Lines changed: 9 additions & 17 deletions

File tree

apps/sim/tools/apollo/sequence_add_contacts.ts

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,9 @@ export const apolloSequenceAddContactsTool: ToolConfig<
129129

130130
request: {
131131
/**
132-
* Apollo runs on Rails, which merges query-string and request-body params into a single
133-
* `params` hash. Scalar settings stay in the query string (matching the docs), but the
134-
* potentially large `contact_ids`/`label_names` arrays are sent in the JSON body to avoid
135-
* exceeding reverse-proxy URL length limits (100 UUIDs ≈ 3.6 KB on their own).
132+
* Apollo documents every field for this endpoint as a query parameter (no request body),
133+
* so `contact_ids[]`/`label_names[]` are appended to the query string alongside the scalar
134+
* settings, matching the documented contract.
136135
*/
137136
url: (params: ApolloSequenceAddContactsParams) => {
138137
const hasContactIds = !!params.contact_ids?.length
@@ -145,6 +144,12 @@ export const apolloSequenceAddContactsTool: ToolConfig<
145144
const qs = new URLSearchParams()
146145
qs.set('emailer_campaign_id', params.sequence_id)
147146
qs.set('send_email_from_email_account_id', params.send_email_from_email_account_id)
147+
for (const id of params.contact_ids ?? []) {
148+
if (typeof id === 'string' && id.length > 0) qs.append('contact_ids[]', id)
149+
}
150+
for (const name of params.label_names ?? []) {
151+
if (typeof name === 'string' && name.length > 0) qs.append('label_names[]', name)
152+
}
148153
if (params.send_email_from_email_address) {
149154
qs.set('send_email_from_email_address', params.send_email_from_email_address)
150155
}
@@ -194,22 +199,9 @@ export const apolloSequenceAddContactsTool: ToolConfig<
194199
},
195200
method: 'POST',
196201
headers: (params: ApolloSequenceAddContactsParams) => ({
197-
'Content-Type': 'application/json',
198202
'Cache-Control': 'no-cache',
199203
'X-Api-Key': params.apiKey,
200204
}),
201-
body: (params: ApolloSequenceAddContactsParams) => {
202-
const body: Record<string, unknown> = {}
203-
const contactIds = (params.contact_ids ?? []).filter(
204-
(id): id is string => typeof id === 'string' && id.length > 0
205-
)
206-
const labelNames = (params.label_names ?? []).filter(
207-
(name): name is string => typeof name === 'string' && name.length > 0
208-
)
209-
if (contactIds.length > 0) body.contact_ids = contactIds
210-
if (labelNames.length > 0) body.label_names = labelNames
211-
return body
212-
},
213205
},
214206

215207
transformResponse: async (response: Response, params?: ApolloSequenceAddContactsParams) => {

0 commit comments

Comments
 (0)