Search Query and Filters

The Search API allows you to search records within a given type (scope) of data.

Available Scopes

Usage

The search scope is required. A simple search looks like this:

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge"

The above example returns all charges on your account with the most recently created charges appearing first (order=reverse_chronological). The response is the first page (page=1) of paginated results with a default of 30 results per page (per_page=30). See Search API for all accepted parameters, object structure, and more examples.

You can add query and filters keys for more complex searches. When both query and filters are supplied, the result is the combined set.

Queries

When the query parameter is supplied, returned objects are those where the query string is found across one of a set of attributes specific to that scope.

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "query=somchai"

The above example returns charges where the string "somchai" is found across one of the searchable query attributes (e.g. customer_name, description, etc.)

Filters

When the filters parameter is supplied, returned objects are those which match the conditions set by the filters object.

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[amount]=1000"

The above example returns charges where the amount field is exactly 1000 currency units (USD, THB, JPY, etc.).

Note: for searching amount fields, use the commonly accepted currency unit, not the smallest currency unit. So, a charge created with amount 100000 and currency USD is searchable as 1000.

Booleans

For boolean (true or false) filters, some natural language equivalents are acceptable.

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[captured]=yes"

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[captured]=on"

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[captured]=no"

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[captured]=off"

Ranges

For numeric and date filters, ranges and some natural language equivalents are acceptable.

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[amount]=1000..2000"

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[created]=2019/01/01..2019/12/31"

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=charge" \
     -d "filters[created]=this_month"

The first example conducts a search for charges where the amount is between 1000 and 2000 (USD, THB, JPY, etc.). The second example conducts a search for charges where the creation date is within the year 2019. The third example conducts a search for charges where the creation date is this month.

Expanding ID Fields

Certain pre-defined fields can return either a reference to another object (via its id) or the object itself. For instance, on a refund object, the charge and transaction attributes are id strings (chrg_xxx and trxn_xxx). Use the expand parameter to return these attributes as charge and transaction objects instead.

curl https://api.omise.co/search \
     -X GET \
     -u $OMISE_SECRET_KEY: \
     -d "scope=refund" \
     -d "expand=true"

Available Queries and Filters

Charge

Use scope=charge to search for Charge records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The charge identifier matching /chrg(_test)?_[0-9a-z]+/.

card_bank

Card bank name. Note: derived from issuer identification number (IIN); may not be accurate.

card_brand

Card brand (e.g. Visa, Mastercard).

card_id

The card identifier matching /card(_test)?_[0-9a-z]+/.

card_name

Card owner name.

customer_description

Description of customer.

customer_email

Email address associated with customer.

customer_id

The customer identifier matching /cust(_test)?_[0-9a-z]+/.

description

Description of charge.

failure_message

Message describing the failure if status == failed.

metadata

Custom metadata (e.g. {"answer": 42}) for charge.

Filters

FilterDescription

amount

Amount for charge in common currency unit. For example, use 1000 for 1000 THB.

authorized

Whether the charge has been authorized.

capture

Whether the charge is set to be auto-captured.

captured

Whether the charge has been paid (also searchable as paid).

captured_at

UTC datetime of the charge payment in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ) (also searchable as paid_at).

card_last_digits

Last 4 digits of card number.

created

UTC datetime of the creation of the charge in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

currency

Currency for charge as three-letter ISO 4217 code.

customer_present

Whether charge has a customer attached.

disputed

Whether charge is disputed.

failure_code

Failure code if status == failed. See testing for possible codes.

is_installment

Whether charge is installment.

refunded

Whether charge has been refunded.

refund_amount

Amount for refund in common currency unit. For example, use 1000 for 1000 THB.

reversed

Whether the charge authorization has been reversed.

safe

Whether charge is safe. A safe charge is one which has successfully passed our fraud protection process.

source_of_fund

Payment mode. One of card, offsite, or offline.

source_type

The payment source type. Value can be one of the following (depending on account and country):

  • internet_banking_bay
  • internet_banking_ktb
  • internet_banking_scb
  • internet_banking_bbl
  • alipay
  • barcode_alipay
  • bill_payment_tesco_lotus
  • installment_bay
  • installment_first_choice
  • installment_bbl
  • installment_ktc
  • installment_kbank
  • econtext
  • truemoney
See installments for allowed values.

status

Charge status. One of failed, expired, pending, reversed or successful.

voided

Whether the charge has been voided.

installment_terms

Installment term in months. See installments for allowed values (type=installment_*).

Customer

Use scope=customer to search for Customer records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The customer identifier matching /cust(_test)?_[0-9a-z]+/.

description

Description of customer.

email

Email address associated with customer.

metadata

Custom metadata (e.g. {"answer": 42}) for customer.

Filters

FilterDescription

created

UTC datetime of the creation of the customer in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Dispute

Use scope=dispute to search for Dispute records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The dispute identifier matching /dspt(_test)?_[0-9a-z]+/.

card_brand

Card brand (e.g. Visa, Mastercard).

card_id

The card identifier matching /card(_test)?_[0-9a-z]+/.

card_name

Card owner name.

metadata

Custom metadata (e.g. {"answer": 42}) for dispute.

message

Explanation for dispute.

reason_code

Dispute reason code.

reason_message

Dispute message associated with the dispute reason code.

Filters

FilterDescription

amount

Amount for dispute in common currency unit. For example, use 1000 for 1000 THB.

card_first_digits

First 6 digits of the card number: the issuer identification number (IIN).

card_last_digits

Last 4 digits of card number.

closed_at

UTC datetime of the closure (i.e. status changed to won or lost) of the dispute in ISO 8601 format.

created

UTC datetime of the creation of the dispute in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

currency

Currency for dispute as three-letter ISO 4217 code.

status

The dispute status. One of open, pending, won or lost. (note: won and lost disputes are retrievable using the /disputes/closed endpoint).

Use scope=link to search for Link records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The link identifier matching /link(_test)?_[0-9a-z]+/.

currency

Currency for link as three-letter ISO 4217 code.

description

Description of link.

link_reference

URI of link.

title

Link title.

Filters

FilterDescription

amount

Amount for link in common currency unit. For example, use 1000 for 1000 THB.

created

UTC datetime of the creation of the link in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

multiple

Whether link is able to be used more than once.

used

Whether link was used.

used_at

UTC datetime of the usage of the link in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Recipient

Use scope=recipient to search for Recipient records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The recipient identifier matching /recp(_test)?_[0-9a-z]+/.

bank_name

Bank account holder name.

bank_brand

Bank account brand (Thailand and Singapore-only).

description

Description of recipient.

email

Email address associated with recipient.

metadata

Custom metadata (e.g. {"answer": 42}) for recipient.

name

Recipient name.

tax_id

Recipient tax ID.

Filters

FilterDescription

active

Whether the recipient is active.

activated_at

UTC datetime of the activation of the recipient in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

bank_last_digits

Last 4 digits of bank account number.

created

UTC datetime of the creation of the recipient in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

deleted

Whether recipient is deleted.

failure_code

Recipient creation failure code. One of name_mismatch, account_not_found, or bank_not_found.

type

Recipient type.

verified

Whether the recipient is verified.

verified_at

UTC datetime of the verification of the recipient in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

Refund

Use scope=refund to search for Refund records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The refund identifier matching /rfnd(_test)?_[0-9a-z]+/.

card_bank

Card bank name. Note: derived from issuer identification number (IIN); may not be accurate.

card_brand

Card brand (e.g. Visa, Mastercard).

card_id

The card identifier matching /card(_test)?_[0-9a-z]+/.

card_name

Card owner name.

charge_description

Description of charge.

currency

Currency for refund as three-letter ISO 4217 code.

metadata

Custom metadata (e.g. {"answer": 42}) for refund.

Filters

FilterDescription

amount

Amount for refund in common currency unit. For example, use 1000 for 1000 THB.

card_first_digits

First 6 digits of the card number: the issuer identification number (IIN).

card_last_digits

Last 4 digits of card number.

created

UTC datetime of the creation of the refund in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

status

Status of the refund. One of pending or closed.

voided

Whether the refund has been voided.

Transfer

Use scope=transfer to search for Transfer records. The following queries and filters are specific to this scope.

Queries

QueryDescription

id

The transfer identifier matching /trsf(_test)?_[0-9a-z]+/.

bank_name

Bank account holder name.

bank_brand

Bank account brand (Thailand and Singapore-only).

failure_code

Failure code for transfer. One of insufficient_balance, invalid_recipient, transfers_suspended, transfer_deleted, transfer_sent, or transfer_failed.

failure_message

Message describing the failure if failure_code exists.

metadata

Custom metadata (e.g. {"answer": 42}) for transfer.

recipient_email

Email address associated with recipient.

recipient_id

RECIPIENT_ID to which the transfer was sent.

recipient_name

The name of the recipient to which the transfer was sent.

transaction_id

The transaction identifier matching /trxn(_test)?_[0-9a-z]+/.

Filters

FilterDescription

amount

Amount for transfer in common currency unit. For example, use 1000 for 1000 THB.

created

UTC datetime of the creation of the transfer in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

currency

Currency for transfer as three-letter ISO 4217 code.

deleted

Whether transfer is deleted.

fee

Omise transfer fee.

paid

Whether the transfer was paid.

paid_at

UTC datetime of the transfer payment in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).

sent

Whether the transfer was sent.

sent_at

UTC datetime of the transfer send event in ISO 8601 format (YYYY-MM-DDThh:mm:ssZ).