---
title: Query Contract
slug: query-contract
createdAt: 2026-02-05T09:33:58.280Z
---

## Purpose

Returns information relating to any contractual term applied to the SIM specified in the \<iccid> element.

This allows you to determine:

- Whether a contract is active&#x20;
- The type of contract applied&#x20;
- How many calendar months remain&#x20;

If no contract is associated with the SIM, both response elements will be returned empty.

### Endpoint

```xml
POST https://api.m2miportal.com
Content-Type: application/xml
Accept: application/xml
```



### Request (XML)

```xml
<query-contract version="1" api-id="123456">
  <authentication>
    <username>username</username>
    <password>password</password>
  </authentication>
  <iccid>1234567890123456789</iccid>
</query-contract>
```

### Response (Success)

```xml
<query-contract-response api-id="123456">
  <api-outcome>Success</api-outcome>  
  <contract-type>1</contract-type>
  <months-remaining>5</months-remaining>
</query-contract-response>

```

### Response Elements

| Element             | Description                                                                                                        |
| ------------------- | ------------------------------------------------------------------------------------------------------------------ |
| \<contract-type>    | Single digit integer: 1 or 2.                                                                                      |
| \<months-remaining> | Integer representing the number of calendar months remaining on the contract. If 0, the contract term has expired. |

If the SIM has no contract associated with it, both elements will be returned empty.

### Contract Types

**Contract Type 1 — Minimum Term**

- SIMs cannot be moved to another group or closed until the contract period has expired.&#x20;
- Many groups operate with a minimum term of one month, meaning the SIM must remain in the group until the calendar month has completed.&#x20;

**Contract Type 2 — Fixed Term**

- Typically includes an initial fee.&#x20;
- Runs for a fixed period.&#x20;
- Group moves are not permitted during the contract period.&#x20;
- At the end of the period, the SIM is automatically deactivated.&#x20;

### Behaviour Notes

- Contracts are evaluated against calendar months.&#x20;
- \<months-remaining> is decremented at midnight UTC at the start of each new calendar month.&#x20;
- A value of 0 indicates that the contract term has expired.

:::hint{type="info"}
## Response (Failure)

If a request cannot be processed, the response will include:

- api-outcome indicating failure&#x20;
- An error description explaining the reason&#x20;

Failure responses may occur due to:

- Invalid authentication credentials&#x20;
- Invalid or unknown identifiers (for example ICCID or MSISDN)&#x20;
- Invalid or missing parameters&#x20;
- Values not permitted for the specified SIM type or account configuration&#x20;
- Insufficient permissions&#x20;

Integrating systems should validate input data before submission and implement appropriate error handling and logging.
:::

