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

# Direct Server API Integration

> Build your own UI for creator boost and payment integration

Build your own creator search/selection/boost UI within your game and call Server APIs directly. Full control over the game UX, but requires UI development.

## When to Use This Method

* You want to build a creator selection UI matching your game's style
* You want seamless integration with your game's UX flow
* You need to control boost registration/removal timing via game logic

## Full Flow

```mermaid theme={null}
sequenceDiagram
    participant U as Game User
    participant C as Game Client
    participant S as Game Server
    participant P as PlayCamp SDK API

    rect rgb(40, 40, 60)
    Note over U,P: 1. Creator Selection (Custom Game UI)
    U->>C: Open creator list screen
    C->>S: Request creator search
    S->>P: Search creators (GET /creators/search)
    P-->>S: Return creator list
    S-->>C: Pass creator list
    U->>C: Select creator
    end

    rect rgb(40, 60, 40)
    Note over U,P: 2. Boost Registration (Server API)
    C->>S: Request boost registration
    S->>P: Register boost (POST /sponsors)
    P-->>S: Return boost result
    S-->>C: Confirmation
    end

    rect rgb(60, 40, 40)
    Note over U,P: 3. Payment Registration (On In-Game Purchase)
    U->>C: In-game purchase
    C->>S: Payment complete notification
    S->>P: Register payment (POST /payments)
    P-->>S: Creator attribution confirmed
    end

    rect rgb(60, 60, 40)
    Note over U,P: 4. Settlement
    Note over P: Monthly settlement → Calculate per-creator revenue
    end
```

## Development Tasks

| # | Task                          | Owner       | Description                             |
| - | ----------------------------- | ----------- | --------------------------------------- |
| 1 | Creator search/selection UI   | Game Client | Creator list, search, selection screens |
| 2 | Creator query API integration | Game Server | Query creator/campaign data             |
| 3 | Boost registration API        | Game Server | User-creator matching                   |
| 4 | Payment registration API      | Game Server | Send in-game purchases                  |
| 5 | (Optional) Webhook receiver   | Game Server | Receive external change events          |

***

## Step 1: Query Creators (Game Server)

Query creator information from your game server to display in your game client.

### Creator Search

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    # Search by keyword
    curl "https://sandbox-sdk-api.playcamp.io/v1/server/creators/search?q=creatorname" \
      -H "Authorization: Bearer ak_server_xxx:secret"

    # Get specific creator details
    curl "https://sandbox-sdk-api.playcamp.io/v1/server/creators/ABC12" \
      -H "Authorization: Bearer ak_server_xxx:secret"
    ```
  </Tab>

  <Tab title="Node SDK">
    ```typescript theme={null}
    // Search by keyword
    const creators = await server.creators.search({ q: 'creatorname' });

    // Get specific creator details
    const creator = await server.creators.get('ABC12');
    ```
  </Tab>

  <Tab title="Go SDK">
    ```go theme={null}
    // Search by keyword
    creators, err := server.Creators.Search(ctx, playcamp.SearchCreatorsParams{
        Q: "creatorname",
    })

    // Get specific creator details
    creator, err := server.Creators.Get(ctx, "ABC12")
    ```
  </Tab>
</Tabs>

### Campaign Creators

You can also query only creators participating in a specific campaign.

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl "https://sandbox-sdk-api.playcamp.io/v1/server/campaigns/campaign_001" \
      -H "Authorization: Bearer ak_server_xxx:secret"
    ```
  </Tab>

  <Tab title="Node SDK">
    ```typescript theme={null}
    const campaign = await server.campaigns.get('campaign_001');
    ```
  </Tab>

  <Tab title="Go SDK">
    ```go theme={null}
    campaign, err := server.Campaigns.Get(ctx, "campaign_001")
    ```
  </Tab>
</Tabs>

> Details: [API Reference - Query Endpoints](/guides/developers/game-integration/reference#server-api-endpoints)

## Step 2: Register Boost (Game Server)

When the user selects a creator, register the boost from your game server.

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://sandbox-sdk-api.playcamp.io/v1/server/sponsors" \
      -H "Authorization: Bearer ak_server_xxx:secret" \
      -H "Content-Type: application/json" \
      -d '{
        "userId": "game_user_id",
        "creatorKey": "ABC12"
      }'
    ```
  </Tab>

  <Tab title="Node SDK">
    ```typescript theme={null}
    const sponsor = await server.sponsors.create({
      userId: 'game_user_id',
      creatorKey: 'ABC12',
    });
    ```
  </Tab>

  <Tab title="Go SDK">
    ```go theme={null}
    sponsor, err := server.Sponsors.Create(ctx, playcamp.CreateSponsorParams{
        UserID:     "game_user_id",
        CreatorKey: "ABC12",
    })
    ```
  </Tab>
</Tabs>

**Response**

```json theme={null}
{
  "data": {
    "userId": "game_user_id",
    "campaignId": "campaign_001",
    "creatorKey": "ABC12",
    "isActive": true,
    "sponsoredAt": "2024-01-15T10:30:00.000Z"
  }
}
```

### Boost Change Rules

`POST /sponsors` operates as an upsert:

| Current State             | Behavior                     |
| ------------------------- | ---------------------------- |
| No boost                  | Create new                   |
| Same creator boosted      | Return current state         |
| Different creator boosted | Change after 30-day cooldown |
| Boost ended               | Reactivate                   |

> Details: [Creator Boost](/guides/developers/game-integration/sponsor)

## Step 3: Register Payments (Game Server)

When an in-game purchase occurs, send the payment information to PlayCamp. It's automatically attributed to the boosted creator.

<Tabs>
  <Tab title="cURL">
    ```bash theme={null}
    curl -X POST "https://sandbox-sdk-api.playcamp.io/v1/server/payments" \
      -H "Authorization: Bearer ak_server_xxx:secret" \
      -H "Content-Type: application/json" \
      -d '{
        "userId": "game_user_id",
        "transactionId": "txn_abc123",
        "productId": "gem_pack_100",
        "productName": "100 Gem Pack",
        "amount": 9900,
        "currency": "KRW",
        "platform": "Android",
        "distributionType": "MOBILE_STORE",
        "purchasedAt": "2024-01-15T10:30:00.000Z"
      }'
    ```
  </Tab>

  <Tab title="Node SDK">
    ```typescript theme={null}
    const payment = await server.payments.create({
      userId: 'game_user_id',
      transactionId: 'txn_abc123',
      productId: 'gem_pack_100',
      productName: '100 Gem Pack',
      amount: 9900,
      currency: 'KRW',
      platform: 'Android',
      distributionType: 'MOBILE_STORE',
      purchasedAt: new Date('2024-01-15T10:30:00Z'),
    });
    ```
  </Tab>

  <Tab title="Go SDK">
    ```go theme={null}
    purchasedAt, _ := time.Parse(time.RFC3339, "2024-01-15T10:30:00Z")

    payment, err := server.Payments.Create(ctx, playcamp.CreatePaymentParams{
        UserID:           "game_user_id",
        TransactionID:    "txn_abc123",
        ProductID:        "gem_pack_100",
        ProductName:      playcamp.String("100 Gem Pack"),
        Amount:           9900,
        Currency:         "KRW",
        Platform:         playcamp.PaymentPlatformAndroid,
        DistributionType: playcamp.String("MOBILE_STORE"),
        PurchasedAt:      purchasedAt,
    })
    ```
  </Tab>
</Tabs>

> Details: [Payment Registration](/guides/developers/game-integration/payment)

## Step 4: (Optional) Webhook Receiver

With direct Server API integration, your game server already knows boost results since it makes the API calls directly. However, webhooks are useful when:

* A PlayCamp admin manually changes a boost
* You want to verify payment registration results asynchronously
* You want to receive coupon redemption events

> Details: [Webhook Events](/guides/developers/game-integration/webhook)

## Step 5: Settlement

Monthly settlement is processed based on payment data.

1. **Revenue Close** — Payment data aggregated at end of each month
2. **Revenue Reconciliation** — Match PlayCamp settlement data with your internal records
3. **Settlement Payment** — Payment after reconciliation confirmation
4. **Creator Settlement** — PlayCamp distributes revenue to creators

> Details: [Settlement](/guides/developers/settlement)
