Getting started
What you need for your first API request and what the API can do today.
Target accepts payments for merchants and routes them to payment providers. The merchant's server talks to the API. This documentation describes only what has been released.
The basics
- The API has one address for the test and live environments:
https://api.thetarget.cc. Every endpoint starts with/api/v1. HTTPS only. - Call the API from your server. There are no CORS headers on purpose: an API key must never end up in the code of a web page or an app.
- Requests and responses are JSON in UTF-8.
- Every request carries an API key. The key identifies the merchant and the environment.
- Amounts are integers of minor currency units, written as strings.
- Every response has a request ID to quote to support.
Your first request
- Get a test key from your Target administrator. How keys work and where they are issued: Authentication.
Put the key in an environment variable on your server. The commands in this documentation read it from there.
export TARGET_API_KEY='the key you were given'Check the key:
curl -sS https://api.thetarget.cc/api/v1/me \ -H "Authorization: Bearer $TARGET_API_KEY"The response contains the merchant, the environment and the public part of the key: fields and an example response. If you get an error, its body names the cause: Errors.
What the API can do today
| Method | Path | What it does |
|---|---|---|
| GET | /api/v1/me | Check the key |
| GET | /api/v1/services | List services |
| POST | /api/v1/payments | Create a payment |
| GET | /api/v1/payments | Find a payment by order number |
| GET | /api/v1/payments/:id | Read a payment |
| POST | /api/v1/payments/:id/refunds | Create a refund |
| GET | /api/v1/payments/:id/refunds | Refunds of a payment |
| GET | /api/v1/payments/:id/refunds/:refundId | Read a refund |
| POST | /api/v1/payouts | Create a payout |
| GET | /api/v1/payouts/:id | Read a payout |
| POST | /api/v1/payouts/:id/cancel | Cancel a payout |
| POST | /api/v1/notifications/secret | Issue the notification signing secret |
A payment is created with one request, the payer pays on the payment page or in your own form, and the outcome comes in a notification or you learn it by reading. A successful payment can be refunded. How it works: Accepting a payment. Live intake is closed; payments are accepted in the test environment. An endpoint appears in the reference and in the changelog on the day it is released, not earlier.