> ## Documentation Index
> Fetch the complete documentation index at: https://docs.shipstream.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Introduction

> Learn the basics of using the Merchant API.

ShipStream exposes all of its API endpoints via HTTP using the JSONRPC protocol. This page explains the general method of authenticating and calling methods. Each method is documented in detail in the additional sections in the sidebar.

<Note>
  See [Find Your URL](/home/find-your-url) for information on finding the correct URL to use for your ShipStream instance.
</Note>

## Request Format

All requests must be POST requests with the request parameters given as a JSON-encoded string in the POST body.

<ParamField path="jsonrpc" type="string" required>
  The JSONRPC protocol version number. Must be "2.0".
</ParamField>

<ParamField path="id" type="string" required>
  A unique identifier for the request that will be included in the response.
</ParamField>

<ParamField path="method" type="string" required>
  The remote procedure to call. This should always be either `login` or `call`.
</ParamField>

<ParamField path="params" type="array" required>
  An array of request parameters specific to the remote procedure being called (see below for details).
</ParamField>

## Response Format

The response will be a JSON-encoded string with the following properties:

<ParamField path="jsonrpc" type="string">
  The JSONRPC protocol version number ("2.0").
</ParamField>

<ParamField path="id" type="string">
  The unique identifier that matches the id given in the request.
</ParamField>

<ParamField path="error" type="object">
  If there is an error, this will be an object with keys `code` and `message`. See "Error Codes" for a list
  of general error codes.
</ParamField>

<ParamField path="result" type="any">
  If an error did not occur this will contain the appropriate response data, otherwise this will be empty.
</ParamField>

## Error Codes

| code   | message          | meaning                                                                                               |
| ------ | ---------------- | ----------------------------------------------------------------------------------------------------- |
| -32700 | Parse error      | Invalid JSON was received by the server. An error occurred on the server while parsing the JSON text. |
| -32600 | Invalid Request  | The JSON sent is not a valid Request object.                                                          |
| -32601 | Method not found | The method does not exist / is not available.                                                         |
| -32602 | Invalid params   | Invalid method parameter(s).                                                                          |
| -32603 | Internal error   | Internal JSON-RPC error.                                                                              |

<Note>
  The error codes are easier to read if you first multiply by -1 and then subtract 32000. From this point forward, all error
  codes mentioned will have this formula already applied to them, but due to the requirement of hte JSONRPC protocol, they
  will be reported via the API without the formula applied.
</Note>

## Calling Methods

`call(session_id, method, arguments)`

The 'call' method requires proper [authentication](/merchant-api/authentication) and is used to call all other API endpoints. These endpoints are detailed in the additional pages in the left sidebar.

### Parameters

<ParamField path="session_id" type="string" required>
  The session ID obtained from calling `login()` or `null` if using HTTP Basic Auth. See [Authentication](/merchant-api/authentication).
</ParamField>

<ParamField path="endpoint" type="string" required>
  The API endpoint to call. This always takes the form of `{resource}.{action}`. E.g. `order.info`
</ParamField>

<ParamField path="arguments" type="array">
  The arguments to the API endpoint. If there are no additional arguments, this parameter may be omitted.
</ParamField>

### Return Value

The response may be any valid JSON type according to the endpoint which was called.

***

### Error Codes

| code | message                                                             |
| ---- | ------------------------------------------------------------------- |
| 2    | Access denied.                                                      |
| 3    | Invalid api path.                                                   |
| 4    | Resource path is not callable.                                      |
| 5    | Session expired. Try to relogin.                                    |
| ?    | Other error codes may be used depending on which method was called. |
