← Selling Partner API (SP-API) + Xero Accounting integrations

Find or Create Contact with Xero Accounting API on New Order Created from Selling Partner API (SP-API) API

Pipedream makes it easy to connect APIs for Xero Accounting, Selling Partner API (SP-API) and 2,800+ other apps remarkably fast.

Trigger workflow on
New Order Created from the Selling Partner API (SP-API) API
Next, do this
Find or Create Contact with the Xero Accounting API
No credit card required
Intro to Pipedream
Watch us build a workflow
Watch us build a workflow
8 min
Watch now ➜

Trusted by 1,000,000+ developers from startups to Fortune 500 companies

Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo
Adyen logo
Appcues logo
Bandwidth logo
Checkr logo
ChartMogul logo
Dataminr logo
Gopuff logo
Gorgias logo
LinkedIn logo
Logitech logo
Replicated logo
Rudderstack logo
SAS logo
Scale AI logo
Webflow logo
Warner Bros. logo

Developers Pipedream

Getting Started

This integration creates a workflow with a Selling Partner API (SP-API) trigger and Xero Accounting action. When you configure and deploy the workflow, it will run on Pipedream's servers 24x7 for free.

  1. Select this integration
  2. Configure the New Order Created trigger
    1. Connect your Selling Partner API (SP-API) account
    2. Configure timer
    3. Select a Marketplace ID
  3. Configure the Find or Create Contact action
    1. Connect your Xero Accounting account
    2. Select a Tenant ID
    3. Optional- Configure Contact name
    4. Optional- Configure Email address
    5. Select a Create a new contact if not found
  4. Deploy the workflow
  5. Send a test event to validate your setup
  6. Turn on the trigger

Details

This integration uses pre-built, source-available components from Pipedream's GitHub repo. These components are developed by Pipedream and the community, and verified and maintained by Pipedream.

To contribute an update to an existing component or create a new component, create a PR on GitHub. If you're new to Pipedream component development, you can start with quickstarts for trigger span and action development, and then review the component API reference.

Trigger

Description:Emit new event when a new order is created in Amazon Seller Central. [See the documentation](https://developer-docs.amazon.com/sp-api/reference/getorders)
Version:0.0.1
Key:amazon_selling_partner-new-order-created

Trigger Code

import common from "../common/base.mjs";

export default {
  ...common,
  key: "amazon_selling_partner-new-order-created",
  name: "New Order Created",
  description: "Emit new event when a new order is created in Amazon Seller Central. [See the documentation](https://developer-docs.amazon.com/sp-api/reference/getorders)",
  version: "0.0.1",
  type: "source",
  dedupe: "unique",
  methods: {
    ...common.methods,
    generateMeta(order) {
      return {
        id: order.AmazonOrderId,
        summary: `New Order: ${order.AmazonOrderId}`,
        ts: Date.parse(order.PurchaseDate),
      };
    },
  },
  async run() {
    const lastTs = this._getLastTs();
    let maxTs = lastTs;

    const orders = await this.amazonSellingPartner.getPaginatedResources({
      fn: this.amazonSellingPartner.listOrders,
      params: {
        MarketplaceIds: this.marketplaceId,
        CreatedAfter: lastTs,
      },
      resourceKey: "Orders",
    });

    if (!orders?.length) {
      return;
    }

    for (const order of orders) {
      if (Date.parse(order.PurchaseDate) > Date.parse(maxTs)) {
        maxTs = order.PurchaseDate;
      }
      const meta = this.generateMeta(order);
      this.$emit(order, meta);
    }

    this._setLastTs(maxTs);
  },
};

Trigger Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI and CLI.
LabelPropTypeDescription
Selling Partner API (SP-API)amazonSellingPartnerappThis component uses the Selling Partner API (SP-API) app.
N/Adb$.service.dbThis component uses $.service.db to maintain state between executions.
timer$.interface.timer
Marketplace IDmarketplaceIdstringSelect a value from the drop down menu.

Trigger Authentication

Selling Partner API (SP-API) uses OAuth authentication. When you connect your Selling Partner API (SP-API) account, Pipedream will open a popup window where you can sign into Selling Partner API (SP-API) and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Selling Partner API (SP-API) API.

Pipedream requests the following authorization scopes when you connect your account:

About Selling Partner API (SP-API)

Selling Partner API (SP-API) allow you to programmatically access data on your orders, shipments, payments, and much more. Applications using the SP-API can increase selling efficiency, reduce labor requirements, and improve response time to customers, helping selling partners grow their businesses.

Action

Description:Finds a contact by name or email address. Optionally, create one if none are found. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)
Version:0.1.0
Key:xero_accounting_api-find-or-create-contact

Xero Accounting Overview

The Xero Accounting API offers a powerful gateway to access and manipulate financial data within Xero. Leveraging Pipedream's capabilities, developers can build custom workflows that streamline accounting processes, sync financial data with external systems, and trigger actions based on financial events. This API allows for the automation of tasks such as invoicing, bank reconciliation, bill payments, and reporting, which can lead to significant time savings and enhanced data accuracy.

Action Code

import { ConfigurationError } from "@pipedream/platform";
import {
  formatQueryString,
  removeNullEntries,
} from "../../common/util.mjs";
import xeroAccountingApi from "../../xero_accounting_api.app.mjs";

export default {
  key: "xero_accounting_api-find-or-create-contact",
  name: "Find or Create Contact",
  description: "Finds a contact by name or email address. Optionally, create one if none are found. [See the docs here](https://developer.xero.com/documentation/api/accounting/contacts/#get-contacts)",
  version: "0.1.0",
  type: "action",
  props: {
    xeroAccountingApi,
    tenantId: {
      propDefinition: [
        xeroAccountingApi,
        "tenantId",
      ],
    },
    name: {
      type: "string",
      label: "Contact name",
      description: "Full name of contact/organization ",
      optional: true,
    },
    emailAddress: {
      type: "string",
      label: "Email address",
      description: "Email address of contact/organization.",
      optional: true,
    },
    createContactIfNotFound: {
      description: "Create a new contact if not found?.",
      label: "Create a new contact if not found",
      type: "string",
      options: [
        "Yes",
        "No",
      ],
      reloadProps: true,
    },
  },
  additionalProps() {
    const props = {};
    if (this.createContactIfNotFound === "Yes") {
      props.firstName = {
        type: "string",
        label: "First name",
        description: "First name of contact person .",
        optional: true,
      };
      props.lastName = {
        type: "string",
        label: "Last name",
        description: "Last name of contact person.",
        optional: true,
      };
      props.contactStatus = {
        type: "string",
        label: "Contact status",
        description:
          "See [contact status reference](https://developer.xero.com/documentation/api/accounting/types#contacts)",
        options: [
          "ACTIVE",
          "ARCHIVED",
          "GDPRREQUEST",
        ],
        optional: true,
        default: "ACTIVE",
      };
    }
    return props;
  },
  async run({ $ }) {
    let contactDetail;
    const {
      tenantId,
      name,
      firstName,
      lastName,
      emailAddress,
      contactStatus,
      createContactIfNotFound,
    } = this;
    if (createContactIfNotFound === "No" && emailAddress && name) {
      throw new ConfigurationError(
        "Choose exclusively between Email Address or Name to find a contact.",
      );
    }
    const findPayload = removeNullEntries({
      Name: name,
      EmailAddress: emailAddress,
    });
    const createPayload = removeNullEntries({
      Name: name,
      FirstName: firstName,
      LastName: lastName,
      EmailAddress: emailAddress,
      ContactStatus: contactStatus,
    });
    try {
      contactDetail = await this.xeroAccountingApi.getContact({
        $,
        tenantId,
        queryParam: formatQueryString(findPayload, true),
      });
    } catch (error) {
      if (createContactIfNotFound === "Yes") {
        $.export("$summary", "Contact not found. Creating new contact");
      } else {
        $.export("$summary", "No contact found.");
        return {};
      }
    }

    if (
      (!contactDetail || !contactDetail?.Contacts?.length) &&
      createContactIfNotFound === "Yes"
    ) {
      return await this.xeroAccountingApi.createOrUpdateContact({
        $,
        tenantId,
        data: createPayload,
      });
    }
    return contactDetail;
  },
};

Action Configuration

This component may be configured based on the props defined in the component code. Pipedream automatically prompts for input values in the UI.

LabelPropTypeDescription
Xero AccountingxeroAccountingApiappThis component uses the Xero Accounting app.
Tenant IDtenantIdstringSelect a value from the drop down menu.
Contact namenamestring

Full name of contact/organization

Email addressemailAddressstring

Email address of contact/organization.

Create a new contact if not foundcreateContactIfNotFoundstringSelect a value from the drop down menu:YesNo

Action Authentication

Xero Accounting uses OAuth authentication. When you connect your Xero Accounting account, Pipedream will open a popup window where you can sign into Xero Accounting and grant Pipedream permission to connect to your account. Pipedream securely stores and automatically refreshes the OAuth tokens so you can easily authenticate any Xero Accounting API.

Pipedream requests the following authorization scopes when you connect your account:

offline_accessopenidprofileemailaccounting.transactionsaccounting.transactions.readaccounting.reports.readaccounting.settingsaccounting.settings.readaccounting.contactsaccounting.attachmentsaccounting.journals.read

About Xero Accounting

Accounting Software

More Ways to Connect Xero Accounting + Selling Partner API (SP-API)

Check FBA Inventory Levels with Selling Partner API (SP-API) API on New or updated contact from Xero Accounting API
Xero Accounting + Selling Partner API (SP-API)
 
Try it
Check FBA Inventory Levels with Selling Partner API (SP-API) API on New or updated invoice from Xero Accounting API
Xero Accounting + Selling Partner API (SP-API)
 
Try it
Fetch Orders by Date Range with Selling Partner API (SP-API) API on New or updated contact from Xero Accounting API
Xero Accounting + Selling Partner API (SP-API)
 
Try it
Fetch Orders by Date Range with Selling Partner API (SP-API) API on New or updated invoice from Xero Accounting API
Xero Accounting + Selling Partner API (SP-API)
 
Try it
Generate Sales & Inventory Reports with Selling Partner API (SP-API) API on New or updated contact from Xero Accounting API
Xero Accounting + Selling Partner API (SP-API)
 
Try it
New Inbound Shipment to FBA Created from the Selling Partner API (SP-API) API

Emit new event when a new inbound shipment to FBA is created. See the documentation

 
Try it
New Order Created from the Selling Partner API (SP-API) API

Emit new event when a new order is created in Amazon Seller Central. See the documentation

 
Try it
New or updated contact from the Xero Accounting API

Emit new notifications when you create a new or update existing contact

 
Try it
New or updated invoice from the Xero Accounting API

Emit new notifications when you create a new or update existing invoice

 
Try it
Webhook Event Received (Instant) from the Xero Accounting API

Emit new event for each incoming webhook notification. To create a Xero Webhook, please follow the instructions here

 
Try it
Check FBA Inventory Levels with the Selling Partner API (SP-API) API

Retrieves inventory summaries from Amazon fulfillment centers to monitor stock availability. See the documentation

 
Try it
Fetch Orders by Date Range with the Selling Partner API (SP-API) API

Retrieves a list of orders based on a specified date range, buyer email, or order ID. See the documentation

 
Try it
Generate Sales & Inventory Reports with the Selling Partner API (SP-API) API

Requests reports on sales, inventory, and fulfillment performance. See the documentation

 
Try it
Get Order Details with the Selling Partner API (SP-API) API

Fetches detailed information about a specific order using its order ID. See the documentation

 
Try it
List Inbound Shipments with the Selling Partner API (SP-API) API

Fetches inbound shipment details to track stock movement and replenishment. See the documentation

 
Try it

Explore Other Apps

1
-
24
of
2,800+
apps by most popular

HTTP / Webhook
HTTP / Webhook
Get a unique URL where you can send HTTP or webhook requests
Node
Node
Anything you can do with Node.js, you can do in a Pipedream workflow. This includes using most of npm's 400,000+ packages.
Python
Python
Anything you can do in Python can be done in a Pipedream Workflow. This includes using any of the 350,000+ PyPi packages available in your Python powered workflows.
Schedule
Schedule
Trigger workflows on an interval or cron schedule.
Pipedream Utils
Pipedream Utils
Utility functions to use within your Pipedream workflows
Notion
Notion
Notion is a new tool that blends your everyday work apps into one. It's the all-in-one workspace for you and your team.
OpenAI (ChatGPT)
OpenAI (ChatGPT)
OpenAI is an AI research and deployment company with the mission to ensure that artificial general intelligence benefits all of humanity. They are the makers of popular models like ChatGPT, DALL-E, and Whisper.
Anthropic (Claude)
Anthropic (Claude)
AI research and products that put safety at the frontier. Introducing Claude, a next-generation AI assistant for your tasks, no matter the scale.
Google Sheets
Google Sheets
Use Google Sheets to create and edit online spreadsheets. Get insights together with secure sharing in real-time and from any device.
Telegram
Telegram
Telegram, is a cloud-based, cross-platform, encrypted instant messaging (IM) service.
Google Drive
Google Drive
Google Drive is a file storage and synchronization service which allows you to create and share your work online, and access your documents from anywhere.
Google Calendar
Google Calendar
With Google Calendar, you can quickly schedule meetings and events and get reminders about upcoming activities, so you always know what’s next.
Shopify
Shopify
Shopify is a complete commerce platform that lets anyone start, manage, and grow a business. You can use Shopify to build an online store, manage sales, market to customers, and accept payments in digital and physical locations.
Supabase
Supabase
Supabase is an open source Firebase alternative.
MySQL
MySQL
MySQL is an open-source relational database management system.
PostgreSQL
PostgreSQL
PostgreSQL is a free and open-source relational database management system emphasizing extensibility and SQL compliance.
Premium
AWS
AWS
Amazon Web Services (AWS) offers reliable, scalable, and inexpensive cloud computing services.
Premium
Twilio SendGrid
Twilio SendGrid
Send marketing and transactional email through the Twilio SendGrid platform with the Email API, proprietary mail transfer agent, and infrastructure for scalable delivery.
Amazon SES
Amazon SES
Amazon SES is a cloud-based email service provider that can integrate into any application for high volume email automation
Premium
Klaviyo
Klaviyo
Email Marketing and SMS Marketing Platform
Premium
Zendesk
Zendesk
Zendesk is award-winning customer service software trusted by 200K+ customers. Make customers happy via text, mobile, phone, email, live chat, social media.
Premium
ServiceNow
ServiceNow
The smarter way to workflow
Slack
Slack
Slack is a channel-based messaging platform. With Slack, people can work together more effectively, connect all their software tools and services, and find the information they need to do their best work — all within a secure, enterprise-grade environment.
Microsoft Teams
Microsoft Teams
Microsoft Teams has communities, events, chats, channels, meetings, storage, tasks, and calendars in one place.