Creating and Publishing Quotes via API

I’m using Zapier to create and publish quotes automatically via api calls. It’s all working pretty well, except that all of our quotes are defaulting to the wrong domain. When I create a new quote template it defaults to our blog.company.com domain, and I always change it to our invoice.company.com domain.

When I manually create or edit quotes they use the invoice.company.com domain but if I create and publish a quote strictly through api, it uses blog.company.com, until I go in and manually unpublish and republish it. Does anyone know why this happens or can anyone help me?

Here’s a boiled down version of the code I’m using. I added an extra step of changing the quote template in hopes that would help but it didn’t. I have also tried unpublishing and republishing the quote via api and that doesn’t help.

async function doStuff(){
theDate=Date.parse('10/20/2024')
console.log(theDate)

var url = 'https://api.hubapi.com/crm/v3/objects/quotes';

var data = {
 properties: {
 hs_title: 'Subscription Quote: test',
 hs_expiration_date: theDate,
 hs_status: "DRAFT",
 hs_language: "en",
 hs_sender_email: 'jeff@breatheforchange.com',
 },
 associations: [
 {
 to: {
 id: 287996186925 // This should be replaced with the actual ID you want to associate with
 },
 types: [
 {
 associationCategory: "HUBSPOT_DEFINED",
 associationTypeId: 286
 }
 ]
 }
 ]

};

var options = {
 method: 'POST',
 headers: {
 'Authorization': `Bearer ${hapi-key}}`,
 'Content-Type': 'application/json'
 },
 body: JSON.stringify(data)
};
var response=await fetch(url, options)
var responseData=await response.json()
var quoteId=responseData.properties.hs_object_id
console.log(responseData);
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/quote_template/285843884972`
options = {
 method: 'PUT',
 headers: {
 'Authorization': `Bearer ${hapi-key}}`,
 'Content-Type': 'application/json'
 },
};
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/deals/16807831318`
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/line_items/7922834188`
response=await fetch(url,options)
responseData=await response.json()
url=`https://api.hubapi.com/crm/v4/objects/quotes/${quoteId}/associations/default/contacts/4114597`
response=await fetch(url,options)
responseData=await response.json()

response = await fetch(
 `https://api.hubapi.com/crm/v3/objects/quotes/${quoteId}`,
 {
 method: 'PATCH',
 headers: {
 'Authorization': `Bearer ${hapi-key}}`,
 'Content-Type': 'application/json',
 },
 body: JSON.stringify({
 properties: {
 hs_status: "APPROVAL_NOT_NEEDED", 
 }
 })
 }
);

console.log('Response status:', response.status);

const text = await response.text();
console.log('Update expiration date response text:', text);

console.log(responseData);
url=`https://api.hubapi.com/crm/v3/objects/quotes/${quoteId}`
options = {
 method: 'GET',
 headers: {
 'Authorization': `Bearer ${hapi-key}}`,
 'Content-Type': 'application/json'
 },
};
response=await fetch(url,options)
responseData=await response.json()
console.log(responseData);

}
doStuff();

Hey @JFenchel

I think you’re encountering an issue where quotes created through the API default to the wrong domain. I have some suggestions to troubleshoot and resolve the problem:

Ensure that the quote template association is set correctly in your API call. Double-check the quote template ID and make sure it is associated with the correct domain.

Then check whether the quote template is set as the default in your HubSpot settings. If the wrong default template is selected, it may override your API call.

Check the details of the quote template associated with your quotes. Ensure that the correct domain is specified within the template settings. Manually review and update the domain within the HubSpot quote template.

Explicitly include the domain information in your API request. Add a property to your quote creation data that specifies the desired domain.

var data = { properties: { hs_title: 'Subscription Quote: test', hs_expiration_date: theDate, hs_status: "DRAFT", hs_language: "en", hs_sender_email: 'jeff@breatheforchange.com', custom_domain: 'invoice.company.com', // Add this line }, // ... (rest of your code) };

Ensure that default settings within HubSpot are configured correctly. Check configurations related to domains, quotes, and any relevant settings that might impact the behavior you’re experiencing.

Thanks for the suggestions! I had tried most of those things, but I was using the wrong domain property. The proper domain property to set is hs_domain and I was trying to set hs_proposal_domain which is read only.