> For AI agents: the complete documentation index is available at /resource/ucidm/docs/on-premise/1.8.0/llms.txt, the full documentation bundle is available at /resource/ucidm/docs/on-premise/1.8.0/llms-full.txt.

# UCIDM API

UCIDM は ID 連携のための Web API を提供します。

[サンプル設定](/resource/ucidm/docs/on-premise/1.8.0/configuration/ucidm-api.md) ではリモートホストから直接 Web API に通信することはできません。お客様の組織のセキュリティポリシーにあわせて設定してください。

## 認証を必要としない Web API \{#public-api}

例えば、API サーバーとの疎通確認のために使う ping API は次のように実行します。

```bash
$ curl http://localhost:18080/status/ping
{
  "message":"pong",
  "remoteAddr":"172.18.0.1:49766",
  "realIP":"172.18.0.1",
  "updatedAt":"2025-10-15T03:55:40.107265791Z",
}
```

他にも UCIDM のバージョン情報を取得もできます。

```bash
$ curl http://localhost:18080/status/version
{
  "ucidmVersion":"1.8.0",
  "serverVersion":"fb42590",
  "idFederationClientVersion":"871bd9f",
  "mongoDBVersion":"8.0.3",
  "rabbitMQVersion":"4.0.3"
}
```

## 認証を必要とする Web API \{#private-api}

UCIDM の大半の Web API を呼び出すには認証を必要とします。UCIDM は次の認証に対応しています。

- ベーシック認証
- アカウント認証
- LDAP 認証
- SAML 認証

アカウント認証により、アクセストークンを取得して Web API を呼び出すには ucidm-cli コマンドを使うと便利です。

```bash
$ cp /opt/osstech/share/ucidm/exports-ucidm-cli.sh .
$ vi exports-ucidm-cli.sh  # 接続先の設定に変更します
export API_SCHEME="http"
export API_HOST="localhost"
export API_PORT="18080"
export API_ACCOUNT_AUTH_USER="${任意のアカウント}"
export API_ACCOUNT_AUTH_PASSWORD="${アカウントのパスワード}"
$ source exports-ucidm-cli.sh
```

ucidm-cli の token サブコマンドでアクセストークンを取得できます。次のように実行すると AT という環境変数にアクセストークンがセットされます。

```bash
$ eval $(/opt/osstech/bin/ucidm-cli token)
$ echo $AT  # アクセストークンの値を確認
eyJhbGc...
```

ヘッダーにアクセストークンを指定して Web API を呼び出します。

```bash
$ curl --header "Authorization: Bearer ${AT}" \
        "http://localhost:18080/p/ping"
{
  "message": "pong",
  "remoteAddr": "172.18.0.1:44582",
  "realIP": "172.18.0.1",
  "updatedAt":"2025-10-15T04:04:47.220276229Z"
}
```

認証を行わない場合は 401 エラーが返ります。

```bash
$ curl -i http://localhost:18080/p/ping
HTTP/1.1 401 Unauthorized
Content-Type: application/json
Www-Authenticate: basic realm=Restricted
Date: Wed, 15 Oct 2025 04:05:55 GMT
Content-Length: 27

{"message":"Unauthorized"}
```

## UCIDM API ドキュメント

Web API の仕様については UCIDM API にドキュメントを同梱しています。リモートホストからブラウザでアクセスするには [Reverse Proxy](/resource/ucidm/docs/on-premise/1.8.0/configuration/proxy.md) を設定してください。

- **Web API の仕様は将来のバージョンで変更する可能性があります**

```
http://localhost:18080/docs
```
