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

# Getting started

> Request credentials, obtain an RS256 access token, search for a company, and look it up — in about fifteen minutes.

This guide walks you through your first successful calls: get a token, find a company, and read its profile. You should be able to finish it in about fifteen minutes.

Use the **sandbox** for this walkthrough. A production database or offline report can create a billable order. Sandbox calls never do that.

## 1. Request credentials

INRA issues a `client_id` and `client_secret` for your organisation. Email [inraasth@inra.co.th](mailto:inraasth@inra.co.th) to request a sandbox credential first, and a separate production credential when you are ready to go live.

We send these once, out of band — not from this page. Store the secret in your own secret manager. Do not put it in a mobile app, a front-end bundle, source control, or a screenshot. If a secret is ever lost or leaked, ask us to rotate it; the old value stops working immediately.

The examples below use placeholders. Replace them with the values you were issued.

```bash theme={null}
export CLIENT_ID="your-client-id"
export CLIENT_SECRET="your-client-secret"
export BASE="https://partners-sandbox.inra.co.th"
```

## 2. Request an access token

The API uses OAuth 2.0 client credentials. Authenticate to the token endpoint with HTTP Basic (`client_id` as the username, `client_secret` as the password), then use the access token as a Bearer token on every `/v1` call.

`POST /oauth/token` always returns JSON, even if you usually prefer XML.

```bash cURL theme={null}
curl -s -u "$CLIENT_ID:$CLIENT_SECRET"   -d grant_type=client_credentials   "$BASE/oauth/token"
```

```python Python theme={null}
import os
import requests

base = os.environ["BASE"]
response = requests.post(
    f"{base}/oauth/token",
    data={"grant_type": "client_credentials"},
    auth=(os.environ["CLIENT_ID"], os.environ["CLIENT_SECRET"]),
    timeout=30,
)
response.raise_for_status()
token = response.json()["access_token"]
```

A successful response looks like this:

```json theme={null}
{
  "access_token": "eyJ...",
  "token_type": "Bearer",
  "expires_in": 900,
  "scope": "companies:search companies:read reports:database reports:offline orders:read"
}
```

Details that matter in production code:

* The access token is an RS256 JWT and is valid for **15 minutes**. Request a new one when it is close to expiry; there is no refresh token.
* You can verify the signature with the keys at `GET /.well-known/jwks.json`. The token header carries a `kid` (`sandbox-1` in the sandbox, `prod-1` in production).
* The token is scoped. If you call an endpoint your client has not been granted, the API returns `403` with the code `insufficient_scope`.
* If the client id or secret is wrong, the token endpoint returns the standard OAuth error `invalid_client`, not the `/v1` error envelope.
* The token endpoint itself is limited to 30 requests per minute per client.

There is a longer note on tokens, scopes, and rotation in [Authentication](https://docs.partners.inra.co.th/guides/authentication.md).

## 3. Search for a company

Resource responses **default to XML**. Send `Accept: application/json` when you want JSON.

Company search matches a name with `contains` by default (at least three characters after wildcard characters are stripped), or matches a 13-digit registration number exactly.

In the sandbox the catalogue is small and deliberate. Searching a real Thai company name will usually return nothing. Use the samples below instead.

```bash cURL theme={null}
curl -s -H "Authorization: Bearer $TOKEN"   -H "Accept: application/json"   "$BASE/v1/companies?name=Sample"
```

```python Python theme={null}
headers = {
    "Authorization": f"Bearer {token}",
    "Accept": "application/json",
}
companies = requests.get(
    f"{base}/v1/companies",
    params={"name": "Sample"},
    headers=headers,
    timeout=30,
)
companies.raise_for_status()
print(companies.json())
```

Useful sandbox queries:

| Query | What you should see |
| - | - |
| `name=Sample` | Sample companies whose English or Thai name contains "Sample" |
| `name=Other` | A different sample set |
| `name=แซมเพิล` | The Thai-name equivalents |
| `name=Sample&match=prefix` | Only names that start with "Sample" |
| `reg_no=0105550000001` | A single company, matched on all 13 digits |

Each hit includes a `company_id`. You will need that id for lookup and for ordering a report. One sandbox company (`100003`) can be found in search but has no database report — that is intentional, so you can practise the `report_not_available` case.

In production, `company_id` is INRA's nine-digit [public identifier](https://docs.partners.inra.co.th/concepts/public-id.md), and only companies with a [Thai address](https://docs.partners.inra.co.th/concepts/coverage.md) are returned. Sandbox ids such as `100001` do not work in production.

## 4. Look up the company

```bash cURL theme={null}
curl -s -H "Authorization: Bearer $TOKEN"   -H "Accept: application/json"   "$BASE/v1/companies/100001"
```

```python Python theme={null}
profile = requests.get(
    f"{base}/v1/companies/100001",
    headers=headers,
    timeout=30,
)
profile.raise_for_status()
print(profile.json())
```

The profile repeats the search fields and is the source of `database_report`: if that flag is `true`, you can order an on-file report for this company.

## 5. Optional: download a sandbox database report

This step is safe in the sandbox. Skip it against production until you intend to place a real order.

```bash cURL theme={null}
curl -s -H "Authorization: Bearer $TOKEN"   -H "Accept: application/json"   -H "Content-Type: application/json"   -d '{"company_id":100001,"reference":"getting-started-1"}'   "$BASE/v1/database-reports"
```

```python Python theme={null}
report = requests.post(
    f"{base}/v1/database-reports",
    headers={**headers, "Content-Type": "application/json"},
    json={"company_id": 100001, "reference": "getting-started-1"},
    timeout=30,
)
report.raise_for_status()
print(report.json()["order_id"])
```

Sandbox companies that have a report:

| `company_id` | Legal form | Notes |
| - | - | - |
| `100001` | Private limited company | The most complete sample; a good first download |
| `100002` | Limited partnership | Partnership (`partners`) block is populated |
| `100005` | Public limited company | PCL-style directors and shareholders |
| `100006` | Bank | Includes bank financial-statement items |
| `100007` | Registered ordinary partnership (ROP) | ROP structure |

The reports are based on real INRA reports that have been masked: personal names, registration numbers, contact details, and other identifiers are replaced consistently throughout each file. Figures are adjusted. Treat them as realistic in shape, not as information about any actual company.

You can fetch the order again with `GET /v1/orders/{order_id}`.

## 6. When something goes wrong

Every `/v1` error uses a small envelope with a stable `code`, a human `message`, and a `request_id`. The same shape is used in JSON and XML. Every response also carries the `X-Request-Id` header — please include it when you email [inraasth@inra.co.th](mailto:inraasth@inra.co.th).

```json theme={null}
{
  "error": {
    "code": "company_not_found",
    "message": "No company matched the request.",
    "request_id": "..."
  }
}
```

Codes you are most likely to see on day one:

| HTTP | `code` | Typical cause |
| - | - | - |
| 401 | `unauthorized` | Missing or expired Bearer token |
| 404 | `company_not_found` | The company id is not in this environment |
| 404 | `report_not_available` | The company exists, but has no database report |
| 406 | `not_acceptable` | `Accept` and `format` disagree |
| 422 | `validation_error` | A parameter or body field failed validation |
| 429 | `rate_limited` | You exceeded the per-minute quota; wait for `Retry-After` |

A full list lives on the [Errors](https://docs.partners.inra.co.th/errors.md) page.

## Next steps

* [Authentication](https://docs.partners.inra.co.th/guides/authentication.md) — scopes, token lifetime, JWKS, and rotating a secret
* [Sandbox vs production](https://docs.partners.inra.co.th/guides/sandbox-vs-production.md) — what is masked, what is identical, and what is billed
* [Company search](https://docs.partners.inra.co.th/guides/company-search.md) — matching rules and how to choose a `company_id`
* [Database reports](https://docs.partners.inra.co.th/guides/database-reports.md) and [Offline reports](https://docs.partners.inra.co.th/guides/offline-reports.md)
* [Dictionaries](https://docs.partners.inra.co.th/dictionaries/overview.md) — codes and names you can cache
* The [API reference](https://docs.partners.inra.co.th/api-reference/authentication/oauth-20-client-credentials.md) — every endpoint, with a playground

If something in this guide does not match what the API returns, please email [inraasth@inra.co.th](mailto:inraasth@inra.co.th) and include the `X-Request-Id`. The documentation should follow the API, not the other way around.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.