Skip to content

Search customers with filters

Open .md

POST/v1/api/store/{team_slug}/customer/filter

v1Operation ID v1_public_customer_filter

Lists customers that match every filter you send, sorted the way you ask. System customers are never returned. Deleted customers are left out unless you filter on trashed_only.

Each filter is {key, operator, value}; all of them must match. What operator and value may be depends on the key:

key Means operator value
assigned_users Assigned to any of these users in, nin Array of user ids. system-current-user means you.
assigned_to_me Assigned to you eq true
tag Has any of these tags in, nin Array of tag ids
hide Archived eq, neq true or false (JSON booleans)
tax_exempt Tax exempt eq, neq true or false
trashed_only Deleted customers only eq true
external_type Synced from Shopify in, nin ["shopify"]
ordered_amount, unpaid_amount, deposit_due_amount, overdue_amount, quote_amount, wallet_fund The customer's totals eq, gte, lte Send a whole number of thousandths: 100000 is 100.00
last_ordered_date Last order date eq, gte, lte Whole days from today (UTC), see below

last_ordered_date filters by a whole number of days from today (in UTC):

Operator Compares with Example Meaning
eq N Whole UTC day N days from today 0 or -1 Ordered today (0) or yesterday (-1)
gte N On or after now plus N days -30 Ordered in the last 30 days (gte -30)
lte N On or before now minus N days 90 Inactive for 90+ days (not ordered in last 90 days: lte 90)

Because gte adds days and lte subtracts days, use negative numbers with gte to look back in time, and positive numbers with lte. Customers who never ordered have no last_ordered_date and never match. (Sales order v2 date filters work differently; see Filtering and sorting).

sort is a list of {key, direction}, applied in order. Sort keys: name, last_ordered_date, ordered_amount, unpaid_amount, deposit_due_amount, wallet_fund, overdue_amount, quote_amount, created_at; direction is asc or desc. Without sort the order is not defined, so always sort when you page.

The list is paged: pagination gives total, count, perPage, currentPage and totalPages. Ask for the next page with page; the page size is the team's setting (50 unless changed), and per_page is ignored. Send page in the body or the query string.

Permission

Needs the Manage Customers permission. At "Manage Assigned to User" only customers assigned to you are searched; without it the answer is 403.

Business rules

  • Booleans must be JSON true or false, not strings. Amounts and day counts must be numbers. Id lists must be arrays, even for one id.
  • There is no name, email or keyword filter on this operation. To find a customer by email, see the notes of Create or update a customer by contact.
  • trashed_only returns deleted customers whatever its value; leave it out to get live ones.
  • tag with nin returns customers that have at least one tag outside the list; customers with no tags are not returned.
  • assigned_users with nin works the same way: customers with at least one assigned user outside the list. Customers nobody is assigned to are not returned.
  • Send amount values as whole numbers of thousandths (100000 is 100.00). Do not send fractions or numbers with a decimal point (such as 100000.5): they pass initial validation but cause an HTTP 500 server error.

Path parameters

  • team_slugstringrequired

    Your team slug, shown as Team ID next to your API key in Profile.

    • Example your-team

Query parameters

  • pageinteger

    The page to return. Pages hold the team's page size (pagination_per_page in team settings: 50 unless changed, 5 to 100). per_page is not read here.

    • Default 1
    • Minimum 1
    • Example 1

Request body

application/json, optional.

  • filtersarray of objects

    Filters that must all match. Leave the key out for no filter; an empty list is refused.

    • At least 1 item
    Fields of each item (3)
    • keystringrequired
      • One of: "assigned_users", "assigned_to_me", "trashed_only", "overdue_amount", "quote_amount", "deposit_due_amount", "unpaid_amount", "ordered_amount", "last_ordered_date", "wallet_fund", "tag", "hide", "tax_exempt", "external_type"
    • operatorstringrequired
      • One of: "eq", "neq", "gte", "lte", "in", "nin"
    • valueanyrequired

      A boolean, a number or an array of ids, by key (see the table).

  • pageinteger
    • Minimum 1
  • sortarray of objects
    Fields of each item (2)
    • directionstringrequired
      • One of: "asc", "desc"
    • keystringrequired
      • One of: "name", "last_ordered_date", "ordered_amount", "unpaid_amount", "deposit_due_amount", "wallet_fund", "overdue_amount", "quote_amount", "created_at"
More examples (2)

Customers who owe more than 100.00, biggest first

curl
curl -X POST 'https://secure.yoprint.com/v1/api/store/your-team/customer/filter' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -H 'Accept: application/json' \  -H 'X-Yoprint-Decimal-Format: exact-v1' \  -H 'Content-Type: application/json' \  -d '{    "filters": [      {        "key": "unpaid_amount",        "operator": "gte",        "value": 100000      }    ],    "page": 1,    "sort": [      {        "direction": "desc",        "key": "unpaid_amount"      }    ]  }'

Tagged customers who ordered in the last 30 days

curl
curl -X POST 'https://secure.yoprint.com/v1/api/store/your-team/customer/filter' \  -H 'Authorization: Bearer YOUR_API_KEY' \  -H 'Accept: application/json' \  -H 'X-Yoprint-Decimal-Format: exact-v1' \  -H 'Content-Type: application/json' \  -d '{    "filters": [      {        "key": "tag",        "operator": "in",        "value": [          "zzVW0sylTIm6oo"        ]      },      {        "key": "last_ordered_date",        "operator": "gte",        "value": -30      },      {        "key": "hide",        "operator": "eq",        "value": false      }    ],    "sort": [      {        "direction": "asc",        "key": "name"      }    ]  }'

Response

200Successful response.

  • dataarray of objectsrequired
    Fields of each item (43)
    • created_atstring (date-time)required
    • hidebooleanrequired

      True when the customer is archived.

    • idstringrequired

      The customer id. Use it in paths and as customer_id on sales orders and quotes.

    • is_editablebooleanrequired

      False for Shopify and system customers: they can't be changed through this API.

    • is_externalbooleanrequired
    • is_systembooleanrequired
    • namestring | nullrequired

      Null for a customer created by upsert without a name.

    • tax_exemptbooleanrequired
    • trashedbooleanrequired

      True when the customer is deleted.

    • updated_atstring (date-time)required
    • account_warningobject | null

      Why YoPrint shows a warning next to the customer's name. Null when there is nothing to warn about.

      Child fields (2)
      • open_disputeobject | nullrequired

        The customer's payments under a dispute that is open or under review; null when there is none.

        Child fields (2)
        • countintegerrequired

          How many payments are disputed.

        • payment_amountinteger | number | stringrequired

          The total of the disputed payments, each counted once. Thousandths, an older encoding: 125000 is 125.00. See Money and quantities.

      • owed_amountinteger | number | string | nullrequired

        What the customer owes back because wallet_fund is negative, as a positive amount; null when it is not negative. Thousandths, an older encoding: 125000 is 125.00. See Money and quantities.

    • assigned_usersarray of objects

      The users assigned to the customer. Unlike List the users assigned to a customer, people who have left the team stay in this list.

      Fields of each item (3)
    • Whether the customer's contacts can open the Customer Portal (Portal settings > Customer portal in YoPrint). false: the portal is off for this customer. true, or null (never set), means on.

    • customer_portal_idstring | null

      The id used in the customer's portal address. Null for Shopify customers.

    • Whether the customer can pay online in the portal. Null follows the team setting (and is always null for Shopify customers).

      • One of: "ENABLED", "DISABLED"
    • customer_profilesarray of objects

      Brand profiles.

      Fields of each item (12)
      • address_idstring | nullrequired

        The Ship From address, or null for a profile that has none.

      • company_namestring | nullrequired
      • customer_idstringrequired
      • idstringrequired
      • is_primarybooleanrequired

        New sales orders and quotes for the customer use the primary profile.

      • trashedbooleanrequired
      • addressobject | null

        The Ship From address (an address, as in Customer addresses, without used_by_active_profile), or null.

        Child fields (33)
        • address1string | nullrequired
        • idstringrequired
        • is_current_sourcebooleanrequired

          False for deleted, replaced, Shopify or redacted addresses. Only current addresses can be picked for new documents or edited.

        • is_primarybooleanrequired
        • labelstring | nullrequired
        • revision_numberintegerrequired

          Goes up by one on every saved change. Send it back as base_revision_number when updating the address to protect against concurrent edits.

        • rolestringrequired

          billing or shipping for customer addresses.

        • trashedbooleanrequired
        • address2string | null
        • address_family_idstring | null

          Shared by an address and the copies made when it was edited after use.

        • citystring | null
        • countrystring | null
        • country_codestring | null
        • Customer addresses only: the customer's id.

        • external_typestring | null

          shopify for an address synced from Shopify.

        • hold_stockboolean

          Company locations only; false for customer addresses.

        • Company locations only; false for customer addresses.

        • True for an address synced from Shopify; such addresses are read-only.

        • nexusboolean

          Company locations only; false for customer addresses.

        • notestring | null
        • owner_idstring | null

          The owner's id: for a customer address, the customer's id (the same as customer_id).

        • customer for customer addresses.

          • One of: "customer", "team", "unknown"
        • True once YoPrint has checked the address with its address validator. postal_can_validate says whether it could be checked and postal_is_valid gives the result. Any edit resets it to false.

        • postcodestring | null
        • sourcestring

          customer for customer addresses.

          • One of: "customer", "company_location", "custom", "unknown"
        • statestring | null
        • state_codestring | null
        • superseded_atstring (date-time) | null
        • Set on an old copy: the address that replaced it.

        • True when a brand profile uses it as Ship From. Sent on lists, reads, updates and customer answers; not on create or set-primary.

      • emailstring | null
      • phonestring | null
      • websitestring | null
    • deposit_due_amountinteger | number | string

      Deposits still due. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • The Customer Portal ID shown to people: the override when set, otherwise customer_portal_id. - for Shopify customers.

    • external_typestring | null

      shopify for customers synced from Shopify.

    • held_creditinteger | number | string

      The part of wallet_fund held while a payment is under an open dispute or a provider review: it can't be applied to orders or taken out until the hold ends. Never more than wallet_fund; 0 when wallet_fund is 0 or negative. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • internal_notesstring | null
    • last_ordered_datestring (date-time) | null

      The issue date of the customer's latest published sales order. Null when it has none.

    • mediaarray of objects
    • ordered_amountinteger | number | string

      Total of the customer's published sales orders. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • overdue_amountinteger | number | string

      Unpaid amounts past their payment due date. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • pdfobject
      Child fields (1)
      • invoice_statementstringrequired

        A link that downloads the customer's invoice statement PDF. Its token opens only this customer's statement and stops working 9,000 hours (about a year) after the answer was made. Anyone with the link can download the statement: don't share it.

    • quote_amountinteger | number | string

      Total of open quotes. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • resale_numberstring | null
    • system_typestring | null
    • tagsarray of objects
      Fields of each item (3)
    • How a shipping label for this customer is billed by default. default_carrier_account: YoPrint's label and rate dialogs start on the customer's default carrier account (third-party billing). none: they start with no third-party billing.

      • One of: "none", "default_carrier_account"
    • unpaid_amountinteger | number | string

      What the customer still owes on published sales orders. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • vat_numberstring | null

      The customer's tax number (shown as Tax number in YoPrint).

    • The team's default currency, the one wallet_fund is in. iso is its code.

      Child fields (6)
      • defaultbooleanrequired
      • idstringrequired
      • isostring | nullrequired

        The ISO 4217 code, such as USD.

      • namestring | nullrequired
      • symbolstring | nullrequired
      • trashedbooleanrequired
    • wallet_fundinteger | number | string

      Customer credit balance. Negative when the customer owes credit back, for example after a refund of a payment whose credit was already spent. Thousandths, an older encoding: 125000 is 125.00. Usually a whole number; an amount finer than a thousandth comes back as a number with a fraction (1234.5 is 1.2345), or as a string ("1234.5") when you send X-Yoprint-Decimal-Format: exact-v1. See Money and quantities.

    • websitestring | null
  • statusintegerrequired
  • successbooleanrequired
  • Child fields (6)
    • countintegerrequired
    • currentPageintegerrequired
    • perPageintegerrequired
    • totalintegerrequired
    • totalPagesintegerrequired

Errors

  • 401The API key is missing or wrong (unauthenticated).

  • 403You are not allowed to do this. api_access_not_in_plan: your team's plan doesn't include API access (Pro and above, with an active subscription or trial), so every request answers this until the team upgrades. When your role lacks the permission the operation needs, the body is only {"message": "Insufficient Permission"}. Other refusals use the error envelope, with unauthorized or user_is_not_authorized.

    When
    Your role cannot see customers. This 403 has a short body, {"message": "You do not have permission to view customer"}.
    Fix
    Ask a team owner for the Manage Customers permission.
  • 404Not found. page_not_found: the team slug is unknown, you are not a member of the team, or an id in the path is not one of this team's. code: null, with a message that starts "No query results for": there is no record with that id.

  • 422The request was refused and changed nothing. validation_failed lists what to fix in error.fields; other codes name a business rule, explained in error.message. A few checks answer with only {"message": "..."}. An operation that calls another service (a payment provider, a carrier, an accounting app) can answer connect_timeout ("Please retry again") when that service does not answer in time: the change may or may not have happened there, so read the record back before you retry.

    When
    A filter has an unknown key, an operator its key does not allow or a value of the wrong type (error.fields.filters), or a sort key is not sortable (error.fields.sort). error.code is validation_failed.
    Fix
    Check the table: for example hide takes eq with a JSON boolean, tag takes in with an array.

Notes

  • Ids in value may be hash ids; they are decoded for you.