<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Edward Shin, Author at airSlate Blog | Business automation</title>
	<atom:link href="https://airslate.wpengine.com/author/edward-shin/feed" rel="self" type="application/rss+xml" />
	<link></link>
	<description>How far ahead can workflow automation get your business? The airSlate blog is here to keep you up to date on all the latest developments in digital process automation and team collaboration.</description>
	<lastBuildDate>Tue, 14 Nov 2023 13:01:21 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.1</generator>
	<item>
		<title>Automate eSignature and document workflows for purchase orders: A developer&#8217;s guide</title>
		<link>https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api</link>
					<comments>https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api#respond</comments>
		
		<dc:creator><![CDATA[Edward Shin]]></dc:creator>
		<pubDate>Tue, 19 Sep 2023 15:51:20 +0000</pubDate>
				<category><![CDATA[Digital Evolution]]></category>
		<category><![CDATA[Editor’s Picks]]></category>
		<category><![CDATA[Document Automation Hub]]></category>
		<guid isPermaLink="false">/?p=4667</guid>

					<description><![CDATA[<p>At many companies, it’s common to have the ability to generate purchase orders from data housed in your CRM, ERP, or backend systems. What’s missing is automating the process of getting those documents signed and approved following your company’s business practices. You need a solution that offers seamless integration with your existing systems and is... <a class="article-subtitle-link"  href="https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api" rel="nofollow">Read more</a> <span class="article-subtitle-arrow">&#8594;</span></p>
<p>The post <a href="https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api">Automate eSignature and document workflows for purchase orders: A developer&#8217;s guide</a> appeared first on <a href="https://airslate.wpengine.com">airSlate Blog | Business automation</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>At many companies, it’s common to have the ability to generate purchase orders from data housed in your CRM, ERP, or backend systems. What’s missing is automating the process of getting those documents signed and approved following your company’s business practices.</p>



<p>You need a solution that offers seamless integration with your existing systems and is easy to customize to match your company’s unique business processes. Efficiency in implementation is a plus; the quicker you can set up and automate your processes, the better.</p>



<h2 class="wp-block-heading" id="h-electronic-signature-security-and-compliance">Electronic signature security and compliance</h2>



<p>The solution also needs to comply with eSignature&nbsp; laws and regulations and ensure data security to protect confidential documents and information.</p>



<p><strong>eSignature:</strong> E-Sign Act, UETA</p>



<p><strong>Data Privacy:</strong> GDPR, CPRA, HIPAA-ready</p>



<p><strong>Data Security:</strong> SOC 2 Type II, SHA-256 encryption</p>



<h2 class="wp-block-heading" id="h-how-to-dynamically-generate-purchase-orders-and-embed-esignature-in-your-app">How to dynamically generate purchase orders and embed eSignature in your app</h2>



<p>In this tutorial, we&#8217;ll demonstrate how to generate professional documents populated with backend data using <a href="https://developers.airslate.com/docs?utm_source=web&amp;utm_medium=blog&amp;utm_campaign=purchase_order" target="_blank" rel="noreferrer noopener">Document Automation Hub</a>. We’ll show how to conditionally display terms and conditions based on region, add signature, and seamlessly integrate document workflow and eSignature inside your Next.js or React applications.</p>



<h3 class="wp-block-heading" id="h-purchase-order-app">Purchase Order app</h3>



<p>A basic React app simulating data retrieval from an existing system.</p>



<figure class="wp-block-image size-large"><img fetchpriority="high" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05-1024x541.png" alt="" class="wp-image-4698" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-05.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Purchase Order document</h3>



<p>A DOCX file, that will be used to dynamically generate the purchase order with the provided data. It will conditionally display terms and conditions based on the selected region.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10-1024x541.png" alt="" class="wp-image-4703" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-10.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Embedded signing</h3>



<p>Embed eSignature in your application, website or CRM.</p>



<figure class="wp-block-image size-large"><img decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09-1024x541.png" alt="" class="wp-image-4702" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-09.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Setup: Download the code</h2>



<p>We’ll use a Next.js app to simulate data retrieval from your backend systems by passing data in via an HTML form. <a href="https://github.com/edshin24/purchase-order-app" target="_blank" rel="noreferrer noopener">Download the code here</a> or clone it to a local repository.</p>



<p>git clone https://github.com/edshin24/purchase-order-app</p>



<h2 class="wp-block-heading">Key concepts</h2>



<p>We’ll use <a href="https://developers.airslate.com/docs?utm_source=web&amp;utm_medium=blog&amp;utm_campaign=purchase_order" target="_blank" rel="noreferrer noopener">Document Automation Hub</a>, an API for automating document workflows, to dynamically pre-fill the document, conditionally display terms and conditions, and generate a link for document signing.</p>



<table id="tablepress-11" class="tablepress tablepress-id-11">
<tbody class="row-hover">
<tr class="row-1 odd">
	<td class="column-1">Organization</td><td class="column-2">The environment (or workspace) where you manage Templates and Flows, upload and create documents and forms, organize webhook events, and users.</td>
</tr>
<tr class="row-2 even">
	<td class="column-1">Template</td><td class="column-2">A workflow configuration containing one or more documents or forms.</td>
</tr>
<tr class="row-3 odd">
	<td class="column-1">Flow</td><td class="column-2">An actionable copy of all documents and forms in a Template.</td>
</tr>
</tbody>
</table>
<!-- #tablepress-11 from cache -->


<h2 class="wp-block-heading">Authentication: JWT Grant</h2>



<ol class="wp-block-list">
<li>Create a <a href="https://oauth-login.airslate.com/en/register/with-email?scope=email&amp;response_type=code&amp;client_id=51&amp;redirect_uri=https%3A%2F%2Fdashboard.airslate.io%2Fapi%2Fauth%2Fcode&amp;state=eyJwcm9kdWN0Ijp7InNvdXJjZSI6ImFzRGV2ZWxvcGVycyJ9fQ%3D%3D&amp;display=page&amp;prompt=create&amp;social_prompt=&amp;max_age=0&amp;ui_locales=&amp;acr_values=&amp;auth_token=VKZHVkS8beK2tACKCtnBDh7ZEA9FQgOQvFINyVUj">free developer account</a></li>



<li>Log into the <a href="https://dashboard.airslate.io/dashboard" target="_blank" rel="noreferrer noopener">Automation Hub Dashboard</a></li>



<li>Click Add Application, and enter:</li>
</ol>



<table id="tablepress-12" class="tablepress tablepress-id-12">
<tbody class="row-hover">
<tr class="row-1 odd">
	<td class="column-1">Application name</td><td class="column-2">Purchase Order App</td>
</tr>
<tr class="row-2 even">
	<td class="column-1">Application URL</td><td class="column-2">http://www.test.com</td>
</tr>
</tbody>
</table>
<!-- #tablepress-12 from cache -->


<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08-1024x541.png" alt="" class="wp-image-4701" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-08.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h3 class="wp-block-heading">Generate JWT Token</h3>



<ol class="wp-block-list">
<li>Click on the application you just created → under Recent Applications</li>



<li>Click JWT Token</li>



<li>Create RSA → Copy your private key</li>



<li>Click “Generate token” → Paste your Private key and set the Expiration date</li>
</ol>



<p>Copy the JSON Web Token → We’ll need this to make our API calls.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07-1024x541.png" alt="" class="wp-image-4700" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-07.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Document generation</h2>



<p><a href="https://www.airslate.com/blog/how-to-generate-documents-using-airslate-api/" target="_blank" rel="noreferrer noopener">Document generation</a> gives you the ability to dynamically generate PDFs from Microsoft Word documents by adding custom variables that are later populated with specific data.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01-1024x541.png" alt="" class="wp-image-4694" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-01.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>Automating this step can add time savings, accuracy and consistency to your documents. And using a Word document gives you full control over branding so you can exactly match your business requirements and design.</p>



<h2 class="wp-block-heading">Dynamic content</h2>



<p>Our purchase order contains text tags, conditionals, and a signature field.</p>



<table id="tablepress-13" class="tablepress tablepress-id-13">
<tbody class="row-hover">
<tr class="row-1 odd">
	<td class="column-1">Text Tags</td><td class="column-2">{{Client_Name}}<br />
{{Order_Date}}<br />
{{Address}}<br />
{{City}}, {{State}} {{Zip}}<br />
{{Phone}}</td><td class="column-3">Custom variables we’ll use to pre-fill our document with data we pass in</td>
</tr>
<tr class="row-2 even">
	<td class="column-1">Conditionals</td><td class="column-2">{{if(Terms=‘CA’)}}<br />
{{else((Terms=‘NY’)}}<br />
{{endif}}</td><td class="column-3">Add conditional logic to generate different terms and conditions per region</td>
</tr>
<tr class="row-3 odd">
	<td class="column-1">Fillable Fields</td><td class="column-2">{{t:s;r:n;l:&#8221;Signature_1&#8243;;}}</td><td class="column-3">To collect user input, like a signature field</td>
</tr>
</tbody>
</table>
<!-- #tablepress-13 from cache -->


<p>See “IT Purchase Order.docx” in the root directory of the project to see how it works, or manually add them to your own Word document to get hands-on experience.</p>



<p><em><strong>Tip:</strong> Use straight quotes (not curly quotes!) when adding the signature field.</em></p>



<h2 class="wp-block-heading">Base64 encode</h2>



<p>To prepare the document(s) for upload, we need to encode them in Base64 format.</p>



<p>For simplicity, “IT Purchase Order.docx” has already been encoded as &#8220;IT Purchase Order.docx.base64&#8221;.</p>



<p>To Base64 encode your documents:</p>



<ol class="wp-block-list">
<li>Use a free online Base64 encoder.</li>



<li>Use encodeDocxToBase64.js to encode your documents on your local machine.</li>
</ol>



<p>node encodeDocxToBase64.js &lt;path-to-file.docx&gt;</p>



<p><em><strong>Note:</strong> You can find &#8220;IT Purchase Order.docx.base64&#8221; and &#8220;encodeDocxToBase64.js&#8221; in the root directory of the project.</em></p>



<h2 class="wp-block-heading">Create a Template</h2>



<p>Next, let’s create the Template. A template represents the workflow configuration, documents and forms for your workflow.</p>



<p>Let’s take a look at the curl request example from the docs to see how it works:</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-json" data-lang="JSON" data-show-lang="0"><code>curl --request POST \
  --url https://api.airslate.io/v1/organizations/organization_id/templates \
  --header &#39;Accept: application/json&#39; \
  --header &#39;Authorization: Bearer undefined&#39; \
  --header &#39;Content-Type: application/json&#39; \
  --data &#39;{
    &quot;name&quot;: &quot;My Template&quot;,
    &quot;description&quot;: &quot;Template for HR Office&quot;,
   &quot;redirect_url&quot;: &quot;https://www.pdffiller.com/?mode=view&quot;
}&#39;</code></pre></div>



<table id="tablepress-14" class="tablepress tablepress-id-14">
<tbody class="row-hover">
<tr class="row-1 odd">
	<td class="column-1">…/v1/organizations/organization_id/templates</td><td class="column-2">API endpoint: Requires “organization_id”</td>
</tr>
<tr class="row-2 even">
	<td class="column-1">Accept: application/json</td><td class="column-2">Response in JSON format</td>
</tr>
<tr class="row-3 odd">
	<td class="column-1">Authorization: Bearer undefined</td><td class="column-2">Authentication</td>
</tr>
<tr class="row-4 even">
	<td class="column-1">Content-Type</td><td class="column-2">Request in JSON format</td>
</tr>
<tr class="row-5 odd">
	<td class="column-1">data &#8216;{<br />
  &#8220;name&#8221;: &#8220;My Template&#8221;,<br />
  &#8220;description&#8221;: &#8220;Template for HR Office&#8221;,<br />
  &#8220;redirect_url&#8221;: &#8220;https://www.pdffiller.com&#8221;<br />
}&#8217;</td><td class="column-2">Template name, description, and redirect_url</td>
</tr>
</tbody>
</table>
<!-- #tablepress-14 from cache -->


<h2 class="wp-block-heading">Organization ID</h2>



<p>To get the organization ID, let’s take a look at the curl request example from the docs:</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-json" data-lang="JSON" data-show-lang="0"><code>curl --request GET \
  --url https://api.airslate.io/v1/organizations \
  --header &#39;Accept: application/json&#39; \
  --header &#39;Authorization: Bearer undefined&#39;</code></pre></div>



<p>This call gets all organizations we belong to. We’re also going to take care of a few housekeeping items here to simplify the rest of our API calls.</p>



<p><em><strong>Optional:</strong> You can log in with your free developer account to create an organization (workspace) at </em><a href="https://www.airslate.com/" target="_blank" rel="noreferrer noopener"><em>https://www.airslate.com/</em></a><em>.</em></p>



<h2 class="wp-block-heading">Implement with Axios and Next.js</h2>



<p>It’s straightforward to map the example curl request using axios.</p>



<ol class="wp-block-list">
<li>endpoint: url + query parameters</li>



<li>options: headers for authentication and expected data formats</li>



<li>payload: data; none in this case</li>
</ol>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>// api.js -&gt; API calls to https://api.airslate.io/v1
const getOrganization = async () =&gt; {
  try {
    const endpoint = `${BASE_URL}/organizations?per_page=100`;
    const response = await axios.get(endpoint, { headers: await getHeaders() });
    return response.data.data.find(org =&gt; org.name === ORGANIZATION);

. . .

// getHeaders()
const getHeaders = async () =&gt; {
  const accessToken = await getAccessToken();
  return {
    &#39;Accept&#39;: &#39;application/json&#39;,
    &#39;Authorization&#39;: `Bearer ${accessToken}`,
    &#39;Content-Type&#39;: &#39;application/json&#39;,
  };
};</code></pre></div>



<h2 class="wp-block-heading">Get Access Token</h2>



<p>We’re also going to use this initial API call to check if we have a valid access token and obtain a new one if we don’t have one or if it’s expired.</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>// api.js -&gt; getOrganization (cont’d)
  
. . .
  
} catch (error) {
    if (error.response && error.response.status === 401) {
      console.warn(&#39;Unauthorized request when fetching organizations. Attempting token refresh.&#39;);


      const newToken = await obtainAccessToken();
      setAccessToken(newToken);</code></pre></div>



<h2 class="wp-block-heading">Create a Template with Axios</h2>



<p>Now that we have the organization ID and access token, we’ll create the template by passing in the organization ID, name, description, and redirect_url.</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>const TEMPLATE = &quot;Purchase Order Template&quot;;
const REDIRECT_URL = &quot;https://www.google.com&quot;;

const createTemplate = async (organizationId) =&gt; {
  const endpoint = `${BASE_URL}/organizations/${organizationId}/templates`;


  const payload = {
    name: TEMPLATE,
    description: &quot;Purchase Order Template&quot;,
    redirect_url: REDIRECT_URL
  };


  const response = await axios.post(endpoint, payload, { headers: await getHeaders() });


  return response.data;
};</code></pre></div>



<h2 class="wp-block-heading">Upload document</h2>



<p>After creating the template, we’ll upload one or more documents or forms. In our case, we’re uploading a Word document so we’ll set type to “DOC_GENERATION” and pass in our Base64 encoded document.</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>const DOCUMENT = &quot;IT Purchase Order.docx&quot;;


const uploadDocument = async (organizationId, templateId) =&gt; {
  const endpoint = `${BASE_URL}/organizations/${organizationId}/templates/${templateId}/documents`;


  const payload = {
    name: DOCUMENT,
    type: &quot;DOC_GENERATION&quot;,
    content: getBase64Content()
  };


  return await axios.post(endpoint, payload, { headers: await getHeaders() });
};

const getBase64Content = () =&gt; {
  const filePath = path.join(process.cwd(), &#39;IT Purchase Order.docx.base64&#39;);
  const base64Content = fs.readFileSync(filePath, &#39;utf-8&#39;);
  return base64Content;
};</code></pre></div>



<h2 class="wp-block-heading">Pre-Fill via API Bot</h2>



<p>Document Automation Hub leverages airSlate to handle the embedded signing session. To configure the signing session to pre-fill our documents via the API:</p>



<ol class="wp-block-list">
<li>Log into airslate.com using your free developer account</li>



<li>Click All Templates</li>



<li>Click Configure Template</li>
</ol>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04-1024x541.png" alt="" class="wp-image-4697" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-04.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>4. Click All Bots (lower right of screen)</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02-1024x541.png" alt="" class="wp-image-4695" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-02.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>5. Click Add Bot<br>6. Search for “Pre-fill via API”<br>7. Click Install Bot</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11-1024x541.png" alt="" class="wp-image-4704" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-11.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>8. Click Publish</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03-1024x541.png" alt="" class="wp-image-4696" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-03.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Create a Flow</h2>



<p>Next, we’ll create a Flow → an actionable copy of our documents and forms. This is the step where we’ll pass in our data to dynamically generate our document.</p>



<p><em><strong>Note:</strong> orderData contains the data from the HTML form.</em></p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>const createFlow = async (organizationId, templateId, document, orderData) =&gt; {
  const endpoint = `${BASE_URL}/organizations/${organizationId}/templates/${templateId}/flows`;


  const payload = {
    documents: [
      {
        id: document.id,
        fields: [
          {
            &quot;id&quot;: getFieldIdByName(document, &quot;Order_Date&quot;),
            &quot;type&quot;: &quot;date&quot;,
            &quot;name&quot;: &quot;Order_Date&quot;,
            &quot;value&quot;: orderData.date,
            &quot;placeholder&quot;: &quot;&quot;
          },
          ...
          {
            &quot;id&quot;: getFieldIdByName(document, &quot;Client_Name&quot;),
            &quot;type&quot;: &quot;text&quot;,
            &quot;name&quot;: &quot;Client_Name&quot;,
            &quot;value&quot;: orderData.clientName,
            &quot;placeholder&quot;: &quot;&quot;
          }
        ]
      }
    ]
  };


  const response = await axios.post(endpoint, payload, { headers: await getHeaders() });
  return response.data;
};</code></pre></div>



<h2 class="wp-block-heading">Create a link to the Flow</h2>



<p>Now we’re ready to send out our first Flow. The documents or forms provided in the link can only be submitted once and expires after a set duration of time (in minutes).</p>



<p><em><strong>Note</strong>: roleId is returned in the response when we create a Flow.</em></p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-js" data-lang="JavaScript" data-show-lang="0"><code>// createPurchaseOrder.js
roleId = flow.available_roles[0].id;

// api.js
const distributeFlow = async (organizationId, templateId, flowId, roleId) =&gt; {
  const endpoint = `${BASE_URL}/organizations/${organizationId}/templates/${templateId}/flows/${flowId}/share`;


  const payload = {
    data: [
      {
        auth_method: &quot;none&quot;,
        expire: 60,
        role_id: roleId
      }
    ]
  };


  return await axios.post(endpoint, payload, { headers: await getHeaders() });
};</code></pre></div>



<h2 class="wp-block-heading">Embed eSignature in your app</h2>



<p>We’ll use the URL we retrieved in the last step to embed the signing session within our app.</p>



<div class="hcb_wrap"><pre class="prism off-numbers lang-html" data-lang="HTML" data-show-lang="0"><code>return (
  &lt;div style={{ width: &#39;100%&#39;, height: &#39;100vh&#39; }}&gt;
    &lt;div className=&quot;bg-blue-600 p-5&quot;&gt;
      &lt;h1 className=&quot;text-2xl text-white&quot;&gt;Technology Solutions, Inc.&lt;/h1&gt;
    &lt;/div&gt;
    &lt;iframe
      src={embedUrl}
      style={{
        border: &#39;none&#39;,
        width: &#39;100%&#39;,
        height: &#39;100%&#39;,
        overflow: &#39;hidden&#39;
      }}
      title=&quot;Embedded Docx&quot;
    &gt;&lt;/iframe&gt;</code></pre></div>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="541" src="/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06-1024x541.png" alt="" class="wp-image-4699" srcset="https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06-1024x541.png 1024w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06-300x158.png 300w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06-768x406.png 768w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06-1536x811.png 1536w, https://airslate.wpengine.com/wp-content/uploads/2023/09/purchase-order-workflow-using-api-06.png 1696w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<h2 class="wp-block-heading">Free Developer Account</h2>



<p><a href="https://developers.airslate.com/docs?utm_source=web&amp;utm_medium=blog&amp;utm_campaign=purchase_order" target="_blank" rel="noreferrer noopener">Document Automation Hub</a> is a useful addition to your toolkit with a suite of API capabilities that go beyond eSignature, and includes document workflow, <a href="https://www.airslate.com/blog/build-dynamic-webforms-using-airslate-api/">dynamic webforms</a>, embedded PDF editing, and PDF tools that easily integrate with your existing systems.</p>



<p>Head over to our developer page to <a href="https://oauth-login.airslate.com/en/register/with-email?scope=email&amp;response_type=code&amp;client_id=51&amp;redirect_uri=https%3A%2F%2Fdashboard.airslate.io%2Fapi%2Fauth%2Fcode&amp;state=eyJwcm9kdWN0Ijp7InNvdXJjZSI6ImFzRGV2ZWxvcGVycyJ9fQ%3D%3D&amp;display=page&amp;prompt=create&amp;social_prompt=&amp;max_age=0&amp;ui_locales=&amp;acr_values=&amp;auth_token=VKZHVkS8beK2tACKCtnBDh7ZEA9FQgOQvFINyVUj" target="_blank" rel="noreferrer noopener">create a free developer account</a> and get 250 flows for free. And <a href="https://stackoverflow.com/questions/tagged/signnow" target="_blank" rel="noreferrer noopener">check out our Stack Overflow community</a> to post questions on this demo or on how to use any of our APIs. We regularly check in on questions asked by developers there.</p>



<p><strong>Document Automation Hub docs</strong>:</p>



<ul class="wp-block-list">
<li><a href="https://docs.airslate.io/docs/airslate-api/document-generation" target="_blank" rel="noreferrer noopener">Document Generation</a></li>



<li><a href="https://docs.airslate.io/docs/airslate-api/organizations-api/operations/list-organizations" target="_blank" rel="noreferrer noopener">Get Organizations</a></li>



<li><a href="https://docs.airslate.io/docs/airslate-api/templates-api/operations/create-a-organization-template" target="_blank" rel="noreferrer noopener">Create Template</a></li>



<li><a href="https://docs.airslate.io/docs/airslate-api/templates-api/operations/create-a-organization-template-document" target="_blank" rel="noreferrer noopener">Upload Document</a></li>



<li><a href="https://docs.airslate.io/docs/airslate-api/flows-api/operations/create-a-organization-template-flow" target="_blank" rel="noreferrer noopener">Create a Flow</a> → Pre-fill document with specific data</li>



<li><a href="https://docs.airslate.io/docs/airslate-api/flows-api/operations/create-a-organization-template-flow-share" target="_blank" rel="noreferrer noopener">Create a Flow Link</a> → Embed or send for signature</li>
</ul>



<p>Happy coding! We hope this article helps you automate document workflows and eSignature for your purchase orders.</p>



<div class="cta cta--dark">
<div class="cta-column cta-column__text">
<div class="section-subheadline section-subheadline--primary">Access every workflow automation API you need to transform users’ experience.</div>
</div>
<div class="cta-column cta-column__button"><a class="button button--md" href="https://developers.airslate.com/docs?utm_source=web&#038;utm_medium=blog&#038;utm_campaign=purchase_order" aria-label="Start free trial">Try for free</a></div>
</div>
<p>The post <a href="https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api">Automate eSignature and document workflows for purchase orders: A developer&#8217;s guide</a> appeared first on <a href="https://airslate.wpengine.com">airSlate Blog | Business automation</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://airslate.wpengine.com/automate-esignature-and-document-workflows-for-purchase-orders-using-api/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
