Edits history of script submission #8975 for ' Add Contacts to Sequence (apollo)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Apollo = {
      apiKey: string;
    };
    
    export async function main(
      resource: Apollo,
      sequenceId: string,
      contactIds: string[],
      emailAccountId: string,
      options?: {
        sequenceNoEmail?: boolean;
        sequenceActiveInOtherCampaigns?: boolean;
        sequenceFinishedInOtherCampaigns?: boolean;
      }
    ) {
      const endpoint = `https://api.apollo.io/v1/emailer_campaigns/${sequenceId}/add_contact_ids`;
      const body = {
        async: false,
        contact_ids: contactIds,
        emailer_campaign_id: sequenceId,
        send_email_from_email_account_id: emailAccountId,
        sequence_no_email: options?.sequenceNoEmail,
        sequence_active_in_other_campaigns: options?.sequenceActiveInOtherCampaigns,
        sequence_finished_in_other_campaigns:
          options?.sequenceFinishedInOtherCampaigns,
      };
    
      const response = await fetch(endpoint, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          "Cache-Control": "no-cache",
          "X-Api-Key": resource.apiKey,
        },
        body: JSON.stringify(body),
      });
    
      if (!response.ok) {
        throw new Error(`HTTP error! status: ${response.status}`);
      }
    
      const data = await response.json();
    
      return data.contacts;
    }
    

    Submitted by hugo697 650 days ago

  • nativets
    type Apollo_io = {
    	apiKey: string
    }
    
    export async function main(
    	resource: Apollo_io,
    	sequenceId: string,
    	contactIds: string[],
    	emailAccountId: string,
    	options?: {
    		sequenceNoEmail?: boolean
    		sequenceActiveInOtherCampaigns?: boolean
    		sequenceFinishedInOtherCampaigns?: boolean
    	}
    ) {
    	const endpoint = `https://api.apollo.io/v1/emailer_campaigns/${sequenceId}/add_contact_ids`
    	const body = {
    		async: false,
    		contact_ids: contactIds,
    		emailer_campaign_id: sequenceId,
    		send_email_from_email_account_id: emailAccountId,
    		sequence_no_email: options?.sequenceNoEmail,
    		sequence_active_in_other_campaigns: options?.sequenceActiveInOtherCampaigns,
    		sequence_finished_in_other_campaigns: options?.sequenceFinishedInOtherCampaigns
    	}
    
    	const response = await fetch(endpoint, {
    		method: 'POST',
    		headers: {
    			'Content-Type': 'application/json',
    			'Cache-Control': 'no-cache',
    			'X-Api-Key': resource.apiKey
    		},
    		body: JSON.stringify(body)
    	})
    
    	if (!response.ok) {
    		throw new Error(`HTTP error! status: ${response.status}`)
    	}
    
    	const data = await response.json()
    
    	return data.contacts
    }
    

    Submitted by hugo697 650 days ago