# 계약 조회

원문: https://commerce.bootpay.ai/api/subscription-contract/list

> 구독 계약 목록을 상태 · 고객 · 그룹 · 기간으로 걸러 조회합니다. 계약마다 결제 주기와 다음 결제일이 오고, 날짜를 비우면 오늘 생성된 계약만 나옵니다.

[v1 API 상세 명세](https://commerce.bootpay.ai/api/reference/v1/order-subscriptions)

구독 계약 목록을 조회합니다. 계약마다 상태, 결제 주기, 다음 결제일 등이 함께 옵니다.

## API 엔드포인트

::: endpoint
method: GET
url: https://api.bootapi.com/v1/order_subscriptions
auth: [Basic Auth](https://commerce.bootpay.ai/api/server/authentication)
:::

## 요청 파라미터

::: parameters

| 파라미터 | 타입 | 필수 | 설명 |
|---------|------|------|------|
| order_number | String | N | 주문번호로 필터 (주문 ID가 아닙니다) |
| user_id | String | N | 고객 ID 또는 이 몰의 외부 회원 ID로 필터. 이 몰에 없거나 탈퇴한 회원이면 `404 USER_NOT_FOUND`가 옵니다 |
| user_group_id | String | N | 고객 그룹 ID로 필터 |
| status | String | N | 구독 상태 필터 — 아래 표 참고 |
| request_type | Integer \| String | N | 현재 이 값을 보내면 서버 오류(500)가 발생합니다. 요청 유형별 조회는 [신청 목록](https://commerce.bootpay.ai/api/subscription-contract/requests#4-신청-목록)을 사용합니다 |
| keyword | String | N | 검색 키워드 |
| search_date_from | String | N | 검색 시작일 (계약 생성일 기준) · 별칭 `s_at`. 비우면 오늘 00:00 |
| search_date_to | String | N | 검색 종료일 (계약 생성일 기준) · 별칭 `e_at`. 비우면 오늘 23:59 |
| page | Integer | N | 페이지 번호 (기본: 1) |
| limit | Integer | N | 페이지당 데이터 수 (기본: 20, 최대 100) |

:::

## 구독 상태 코드 (`status`)

| 키 | 값 | 설명 |
|----|----|------|
| `contract_requested_completed` | `0` | 구독 신청 완료, 승인 대기 |
| `subscribing` | `1` | 구독 중 (정상 결제 진행) |
| `auto_terminated` | `15` | 자동 해지 (기간 만료 등) |
| `manual_terminated` | `20` | 직접 해지 (사용자 요청) |
| `mid_term_transfer_approved` | `25` | 중도 인수 승인 |
| `mid_term_transfer_requested` | `26` | 중도 인수 요청 |
| `free_trial` | `-1` | 무료 체험 |
| `temporarily_paused` | `-2` | 일시정지 |
| `paused_due_to_issue` | `-3` | 이슈로 인한 일시정지 |
| `first_payment_error` | `-10` | 첫 결제 오류 |
| `admin_terminated` | `-11` | 관리자 해지 |
| `rejected` | `-12` | 구독 거절 |

:::canvas-flow
{
  "nodes": [
    { "id": "init", "label": "주문서 결제\n주문·계약 생성", "col": 1, "row": 0, "type": "process" },
    { "id": "waiting", "label": "대기\ncontract_requested_completed", "col": 1, "row": 1, "type": "process" },
    { "id": "active", "label": "구독 중\nsubscribing", "col": 1, "row": 2, "type": "success" },
    { "id": "terminated", "label": "해지\nmanual_terminated", "col": 0, "row": 2, "type": "warning" },
    { "id": "paused", "label": "일시정지\ntemporarily_paused", "col": 2, "row": 2, "type": "process" },
    { "id": "expired", "label": "만료\nauto_terminated", "col": 1, "row": 3, "type": "warning" }
  ],
  "edges": [
    { "from": "init", "to": "waiting", "label": "주문 생성" },
    { "from": "waiting", "to": "active", "label": "승인" },
    { "from": "active", "to": "paused", "label": "일시정지" },
    { "from": "paused", "to": "active", "label": "재개" },
    { "from": "active", "to": "terminated", "label": "해지" },
    { "from": "active", "to": "expired", "label": "기간 만료" }
  ],
  "direction": "TB",
  "cols": 3,
  "rows": 4
}
:::

## 코드 예제

::: code-group

```javascript [Node.js]
import { BootpayCommerce } from '@bootpay/backend-js'

const commerce = new BootpayCommerce({
    client_key: 'your-commerce-client-key',
    secret_key: 'your-commerce-secret-key',
    mode: 'production'
})

const response = await commerce.orderSubscription.list({
    page: 1,
    limit: 20,
    status: 'subscribing'
})
console.log(response)
```

```python [Python]
from bootpay_backend import BootpayCommerce

commerce = BootpayCommerce(
    client_key='your-commerce-client-key',
    secret_key='your-commerce-secret-key',
    mode='production'
)

response = commerce.order_subscription.list({'page': 1, 'limit': 20, 'status': 'subscribing'})
print(response)
```

```php [PHP]
use Bootpay\ServerPhp\BootpayCommerceApi;

$commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
$response = $commerce->orderSubscription->getList([
    'page' => 1,
    'limit' => 20,
    'status' => 'subscribing'
]);
print_r($response);
```

```java [Java]
import kr.co.bootpay.store.BootpayStore;
import kr.co.bootpay.store.model.request.TokenPayload;
import kr.co.bootpay.store.model.response.BootpayStoreResponse;
import kr.co.bootpay.store.model.request.orderSubscription.OrderSubscriptionListParams;

TokenPayload tp = new TokenPayload("your-commerce-client-key", "your-commerce-secret-key");
BootpayStore commerce = new BootpayStore(tp).withToken();

OrderSubscriptionListParams params = new OrderSubscriptionListParams();
params.page = 1;
params.limit = 20;
params.status = 1;  // subscribing — Java SDK 의 status 는 Integer 라 숫자로 보냅니다

BootpayStoreResponse response = commerce.orderSubscription.list(params);
System.out.println(response);
```

```ruby [Ruby]
require 'bootpay'

commerce = BootpayStore::RestClient.new(client_key: 'your-commerce-client-key', secret_key: 'your-commerce-secret-key')
response = commerce.order_subscriptions(
  page: 1,
  limit: 20,
  status: 'subscribing'
)
puts response.data
```

```go [Go]
commerce := bootpay.NewCommerceAPI("your-commerce-client-key", "your-commerce-secret-key", nil, "production")
status := 1  // subscribing — Go SDK 는 숫자로 보냅니다
response, err := commerce.OrderSubscription.List(&bootpay.OrderSubscriptionListParams{
    ListParams: bootpay.ListParams{Page: 1, Limit: 20},
    Status:     &status,
})
fmt.Println(response, err)
```

```csharp [.NET]
using Bootpay.Commerce;
using Bootpay.Commerce.Models;

var commerce = new BootpayCommerceApi("your-commerce-client-key", "your-commerce-secret-key");
var response = await commerce.OrderSubscriptionList(new OrderSubscriptionListParams {
    Page = 1,
    Limit = 20,
    Status = 1  // subscribing — .NET SDK 는 숫자로 보냅니다
});
Console.WriteLine(await response.Content.ReadAsStringAsync());
```

:::

## 응답

#### 성공 응답

```json
{
  "count": 3,
  "list": [
    {
      "order_subscription_id": "687a1b2c3d4e5f6789012345",
      "order_number": "68707c59b0eacea5cd974efd",
      "user_id": "67e4b4425ec892162491d0ec",
      "status": "subscribing",
      "approval_status": "approval_approved_auto",
      "subscription_payment_cycle_type": "1month",
      "price": 29900,
      "payment_next_at": "2025-08-01T00:00:00+09:00",
      "service_start_at": "2025-07-01T00:00:00+09:00",
      "created_at": "2025-06-30T15:00:00+09:00"
    }
  ]
}
```

## 응답 필드 설명

| 필드 | 타입 | 설명 |
|------|------|------|
| `count` | Integer | 총 구독 계약 수 |
| `list` | Array | 구독 계약 목록 |
| &nbsp;&nbsp;└─ `order_subscription_id` | String | 구독 계약 고유 ID |
| &nbsp;&nbsp;└─ `order_number` | String | 연결된 주문번호 |
| &nbsp;&nbsp;└─ `status` | String | 구독 상태 — 아래 표 참고 |
| &nbsp;&nbsp;└─ `approval_status` | String | 승인 상태 |
| &nbsp;&nbsp;└─ `subscription_payment_cycle_type` | String | 결제 주기 (`1month`, `1year` 등) |
| &nbsp;&nbsp;└─ `price` | Integer | 회차별 결제 금액 |
| &nbsp;&nbsp;└─ `payment_next_at` | String | 다음 결제 예정일 |
| &nbsp;&nbsp;└─ `service_start_at` | String | 구독 서비스 시작일 |

목록 외에 상태별 집계(`sum_*`)와 요청 유형별 집계(`ing_*`)가 최상위에 함께 옵니다.

## 에러 코드

::: info 공통 에러
인증·권한 관련 에러는 [에러 코드표](https://commerce.bootpay.ai/api/reference/codes#커머스-api-인증-에러)를 참고합니다.
:::

::: error-codes

| 코드 | 메시지 | 대처 방법 |
|------|--------|-----------|
| `INVALID_PARAMETER` | `status` 값을 해석할 수 없습니다. | 숫자 또는 상태 키(`subscribing` 등)로 보냅니다 |
| `USER_NOT_FOUND` | 회원정보가 없습니다. 다시 확인해주세요. | `user_id`가 이 몰의 회원인지, 탈퇴하지 않았는지 확인합니다 |

:::
