# REST API

## 개요

Panther는 Panther 인스턴스의 특정 부분과 상호작용할 수 있는 REST API를 제공합니다. 현재 REST API를 통해 다음 엔터티와 상호작용할 수 있습니다:

* [알러트](https://docs.panther.com/ko/panther/api/rest/alerts)
* [알러트 댓글](https://docs.panther.com/ko/panther/api/rest/alert-comments)
* [알러트 컨텍스트 태그](https://docs.panther.com/ko/panther/api/rest/alert-context-tags)
* [API 토큰](https://docs.panther.com/ko/panther/api/rest/api-tokens)
* [상관관계 룰](https://docs.panther.com/ko/panther/api/rest/correlation-rules)
* [데이터 모델](https://docs.panther.com/ko/panther/api/rest/data-models)
* [전역값](https://docs.panther.com/ko/panther/api/rest/globals)
* [로그 소스](https://docs.panther.com/ko/panther/api/rest/log-sources)
* [쿼리](https://docs.panther.com/ko/panther/api/rest/queries)
* [역할](https://docs.panther.com/ko/panther/api/rest/roles)
* [룰](https://docs.panther.com/ko/panther/api/rest/rules)
* [예약된 룰](https://docs.panther.com/ko/panther/api/rest/scheduled-rules)
* [Simple/YAML 룰](https://docs.panther.com/ko/panther/api/rest/simple-rules)
* [정책](https://docs.panther.com/ko/panther/api/rest/policies)
* [사용자](https://docs.panther.com/ko/panther/api/rest/users)

추가 작업은 다음에서 사용할 수 있습니다 [GraphQL API](https://docs.panther.com/ko/panther/api/graphql).

### Panther REST API 스키마 알아보기

{% tabs %}
{% tab title="OpenAPI 사양" %}
OpenAPI 사양 파일을 다운로드하여 REST API 스키마를 알아보세요:

{% file src="<https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-92ac408a8e96ab4254db2b221a79a4f051129333%2Fpanther_open_api_v3_spec.yaml?alt=media>" %}
{% endtab %}

{% tab title="API Playground " %}
Panther Console의 API Playground를 탐색하여 API 스키마를 알아볼 수 있습니다. 자세한 내용은 다음을 참조하세요 [API Playground](https://docs.panther.com/ko/panther/api/api-playground).
{% endtab %}
{% endtabs %}

## Panther REST API 사용 방법

### 1단계: Panther REST API URL 식별

REST API URL을 찾으려면:

* Panther Console의 오른쪽 상단에서 톱니바퀴 아이콘을 클릭한 다음 **API 토큰**를 클릭합니다. 페이지 상단에서 다음을 확인하세요 **API URL**.

  * 다음을 실행 중인 경우 [SaaS](https://docs.panther.com/ko/system-configuration/panther-deployment-types#saas) Panther 배포의 경우, REST URL은 아래에 표시된 부분이 됩니다:

  <figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-f9b58befbc5316bcf67d46db823deb37d131c63d%2FScreenshot%202023-12-13%20at%2011.35.41%20AM.png?alt=media" alt="An &#x22;API Tokens&#x22; section shows a blurred-out API URL"><figcaption></figcaption></figure>

  * 다음을 실행 중인 경우 [Cloud Connected](https://docs.panther.com/ko/system-configuration/panther-deployment-types#cloud-connected) 또는 [셀프 호스팅](https://docs.panther.com/ko/system-configuration/panther-deployment-types#self-hosted-legacy) Panther 배포의 경우, URL은 아래에 표시된 부분이 됩니다 (다음을 포함 `/v1`):

  <figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-7ee3d76233bab269b7a576612d0b748b05e36d4a%2FScreenshot%202023-12-13%20at%2011.53.34%20AM.png?alt=media" alt="An &#x22;API Tokens&#x22; section shows a blurred-out API URL"><figcaption></figcaption></figure>

{% hint style="warning" %}
모든 REST URL은 다음을 제외한다는 점에 유의하세요 `/public/graphql` 값의 끝에서.
{% endhint %}

### 2단계: API 토큰 생성

* 참조 [API 토큰 생성 방법에 대한 이 지침](https://docs.panther.com/ko/panther/api/..#how-to-create-a-panther-api-token)입니다. 각 REST API 작업에 필요한 권한은 각 엔터티의 페이지(이 페이지 하위에 중첩됨)에서 확인할 수 있습니다. 다음을 참조하세요 [Console 및 API의 권한 이름](https://app.gitbook.com/s/-LgdiSWdyJcXPahGi9Rs-2910905616/system-configuration/rbac#permission-names-in-the-console-and-api) 추가 정보는 여기에서 확인하세요.

### 3단계: Panther REST API 호출

다음을 사용한 테스트 외에도 [API Playground](https://docs.panther.com/ko/panther/api/api-playground) Console에서 Swagger, Postman 또는 이 문서를 사용하여 REST API를 호출할 수 있습니다:

{% tabs %}
{% tab title="Swagger" %}
**Swagger를 사용하여 REST API에 액세스하기**

1. 웹 브라우저에서 다음으로 이동하세요 [Swagger Editor](https://editor.swagger.io/).
2. 왼쪽의 코드 편집기에 위에서 찾은 Panther REST OpenAPI 사양 파일을 다음에 붙여넣으세요 [Panther REST API 스키마 알아보기](#discover-the-panther-rest-api-schema).
3. 오른쪽에서 다음 아래에 있는 **서버 변수**, 다음에서 **api\_host**, 프로토콜 없이(즉, 다음 제외) Panther REST API URL을 입력하세요 `https://`).\
   ![A "Server variables" section shows an api\_host](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-ad21510c92ca6e994a4020bf0c7fcc0cc27bbd75%2FScreenshot%202023-12-11%20at%204.21.46%20PM.png?alt=media)
4. 클릭 **승인**.\
   ![An Authorize button](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-b06f008348e3e869375cc2752c3c7eef4d2b0a04%2FScreenshot%202023-12-11%20at%204.27.00%20PM.png?alt=media)
5. 다음에서 **사용 가능한 승인** 모달:
   1. 다음 아래에서 **값**, API 토큰 값을 입력하세요.
   2. 클릭 **승인**.
   3. 클릭 **닫기**.\
      ![An "Available authorizations" section shows "ApiKeyAuth" section, with a "Value" field. There are "Authorize" and "Close" buttons.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-695da28655f44ba6ecd6804fd04ddc580ea19715%2FUntitled.png?alt=media)
6. 이제 API 호출을 시도할 수 있습니다:
   1. 엔드포인트를 선택하고 아래를 가리키는 화살표를 클릭하여 확장하세요.
   2. 클릭 **사용해 보기**.\
      ![A  "GET /globals" section has a "Try it out" button](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-67bdeb17bbb6d523b4f57decbb0f33ab1d3d87b6%2FScreenshot%202023-12-11%20at%204.36.55%20PM.png?alt=media)
   3. 클릭 **실행**.
      {% endtab %}

{% tab title="Postman" %}
**Postman을 사용하여 REST API에 액세스하기**

Panther Postman 컬렉션을 가져오고, URL 및 API 변수가 있는 새 환경을 만든 다음, 요청 전송을 시도하게 됩니다.

1. 다음을 다운로드하세요 `Panther_REST_API_postman_collection.json` 이 탭 하단에 있는 파일입니다.
2. Postman 애플리케이션에서 다음을 클릭하세요 **파일** > **가져오기**.
3. 다음을 선택하세요 `Panther_REST_API_postman_collection.json` 파일.
   * 다음 아래에서 **컬렉션**, 이제 다음이 생깁니다 **Panther Rest API** 컬렉션.
4. 클릭 **환경**, 그런 다음 더하기 기호를 클릭하세요 (**+**).\
   ![A "My Workspace" section has a plus button with the tooltip "Create new environment"](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-9a6f0eb387487414f1ee19bef6f094fd7de6ec95%2FScreenshot%202023-12-12%20at%204.50.38%20PM.png?alt=media)
5. 환경 이름을 입력하세요. 예: "Panther."
6. 오른쪽 표에 다음 두 변수를 입력하세요:
   * `restHost`: 다음의 경우 **현재 값**, 전체 Panther REST API URL을 입력하세요.
     * 이 값은 다음의 지침을 따라 찾을 수 있습니다 [1단계: Panther REST API URL 식별](#step-1-identify-your-panther-rest-api-url).
   * `restApiToken`: 다음의 경우 **현재 값**, Panther API 토큰을 입력하세요. 다음의 **유형** 열에서 다음을 선택하세요 **secret**.

     <figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-8908857f5542b6786c044134480fcd5217d86b80%2FScreenshot%202024-03-12%20at%203.25.43%20PM.png?alt=media" alt="A table is shown with two rows filled in: one for restHost and one for restApiToken. There is a Type and Current value for each."><figcaption></figcaption></figure>
7. 오른쪽 상단에서 다음을 클릭하세요 **저장**.
8. 이제 요청 전송을 시도할 수 있습니다:
   1. 오른쪽 상단에서 환경 드롭다운을 클릭하고 이전 단계에서 만든 것을 선택하세요.\ <img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-471a8e8281f8a38d0886de2f280d3af0895413bc%2FScreenshot%202023-12-12%20at%205.01.03%20PM.png?alt=media" alt="A drop-down field shows two options: &#x22;No Environment&#x22; and &#x22;Panther&#x22;" data-size="original">
   2. 클릭 **컬렉션**.
   3. 다음을 확장하세요 **Panther Rest API** 컬렉션을 확장한 다음 요청을 선택하세요.
   4. 클릭 **전송**.

{% file src="<https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-c99b09024de00a73825ba379556a2485e2a8883f%2FPanther%20Rest%20API.postman_collection.json?alt=media>" %}
{% endtab %}

{% tab title="이 문서" %}
**Panther 문서를 사용하여 REST API에 액세스하기**

1. REST API 엔터티 페이지 중 하나(이 페이지 하위에 중첩됨)로 이동하여 수행하려는 작업을 찾으세요.
2. 작업의 다음 **요청** 타일 오른쪽 하단에서 다음을 클릭하세요 **▶테스트**.

   <figure><img src="https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-5d9b6f8d7c631e15596f2d26cf2050b3e8780cc8%2FScreenshot%202025-04-15%20at%2012.56.58%E2%80%AFPM.png?alt=media" alt="A &#x22;Get an alert&#x22; section includes cards for &#x22;Path parameters,&#x22; &#x22;Responses,&#x22; and &#x22;Authorizations.&#x22; The &#x22;Test it&#x22; button is circled."><figcaption></figcaption></figure>
3. 팝업되는 모달에서 상단에 표시된 엔드포인트의 다음을 클릭하세요 `{api_host}`.\
   ![In a URL value, the {api\_host} section is circled.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-3a580b6b8d3df90c15946ec26f3db56faa67e280%2FScreenshot%202025-04-15%20at%201.00.48%E2%80%AFPM.png?alt=media)
4. 다음에서 **api\_host** 필드에 1단계에서 식별한 REST API URL을 다음 없이 입력하세요 [1단계](#step-1-identify-your-panther-rest-api-url), 프로토콜 없이(즉, 다음 제외) `https://`).\
   ![There is a circle around "api\_host: my-REST-API-URL."](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-9869e45120a0a5e68289790979661c645de297bc%2FScreenshot%202025-04-15%20at%201.02.38%E2%80%AFPM.png?alt=media)
5. 다음에서 **인증** 섹션에서 다음을 클릭하세요 **인증 유형** 드롭다운.
   1. 다음 아래에서 **필수 인증**, 다음 옆의 상자를 선택하세요 **ApiKeyAuth**.\
      ![Under an "Authentication" header, an arrow is drawn from an "ApiKeyAuth" button to a value labeled "ApiKeyAuth."](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-9cc187a88f9aa27fd161c46bde4ce546e862cc8f%2FScreenshot%202025-04-15%20at%201.17.21%E2%80%AFPM.png?alt=media)
   2. 다음 아래에서 **인증**, **이름** 및 **값** 필드가 채워집니다. 다음에 **값**, 2단계에서 생성한 API 토큰을 입력하세요 [2단계](#step-2-generate-an-api-token).
6. 다음에서 **변수** 섹션에서 작업에 다음과 같은 필수 경로 변수가 있는 경우 `{id}`, 다음에 값을 제공하세요 `VALUE` 열.\
   ![Under a "Get an alert" title, there are sub-sections titled Authentication, Variables, and Cookies. The value of "id" within Variables is circled.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-1404542376554e8a09346e0c6a24529f1d692ec0%2FScreenshot%202025-04-15%20at%201.04.28%E2%80%AFPM.png?alt=media)
7. 다음에 값이 있는 경우 **쿼리 매개변수** 섹션에서, 이 호출에 적용되게 하려면 오른쪽 열의 체크박스를 클릭하세요.\
   ![A "Query Parameters" header is over a table with columns for "KEY," "VALUE," and a three-lines icon. There are two rows filled in, and the third column is circled.](https://2400888838-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LgdiSWdyJcXPahGi9Rs-2910905616%2Fuploads%2Fgit-blob-30046c73238bc09d3dbb79c5f94bbf60b522cfee%2FScreenshot%202024-03-28%20at%2011.42.58%20AM.png?alt=media)
8. 요청에 요청 본문이 필요한 경우 다음 안에 콘텐츠를 추가하세요 **본문**.
9. 클릭 **요청 보내기**.
   {% endtab %}
   {% endtabs %}
