# API Key

## Introduction

This document provides a comprehensive guide to integrating the MPC SDK (SDK) with API key authentication, enabling secure access to the MPC system. By leveraging this integration, developers can enhance the security of their blockchain applications while maintaining ease of use and flexibility.

**Scope**This guide will cover

* The role of API key authentication in securing communication with the MPC server.
* The flow of the integration between each component in the MPC system
* API key usage tracking

This document is intended for developers and technical teams looking to integrate MPC SDK capabilities into their blockchain solutions securely and efficiently.

## Architecture and Integration Flow

Every request access into the MPC system will be treated as a tenant, therefore the usage is tracked by tenant level.

### Architecture

MPC SDK: This is SDK for client interaction with the MPC systemMPC system contains the following components:

* API Gateway: the entry point for all requests from MPC SDK access into MPC system
* MPC server: service handles multi-party computing
* Auth server: before SDK conducts requests into the MPC server, the user must obtain the user token in JWT format from the Auth server.
* MPC usage tracking: each request comes into the MPC server, which will track the usage by this service

![](https://t9018252776.p.clickup-attachments.com/t9018252776/022921b1-fd0b-4c28-9d3d-b105624644bd/Architecture%20and%20Integration%20Flow.drawio%20\(1\).png)

### Integration Flow

**Step 1: Obtain API Key**

Customers must contact **Cramium Labs** to obtain an **API key** for the SDK. This API key should be added to the SDK configuration. *(The contact email* [***info@crossbar-inc.com***](mailto:info@crossbar-inc.com) *needs to be updated.)*

***

#### **Step 2: Test Passkey Authentication with API Key**

Before integrating the SDK, customers can use the **WebAuthn Playground** to test **Passkey authentication** using their API key.🔗 **Playground URL**: \
<https://auth.mpc-dev.cramiumtech.com/playground/> \
The Playground allows users to **register and authenticate using Passkeys**

**Steps to Test in Playground:**

1. **Enter your API key** (obtained in Step 1).
2. **Enter a username** for testing authentication.
3. Click the **Register** button to register a new Passkey.
4. Once registered, click the **Authenticate** button to verify authentication.
5. If successful, the Playground will return a **JWT token** containing **tenant metadata**.

This JWT token can then be used in the SDK to make authenticated requests to the MPC server.

***

#### **Step 3: Authenticate via SDK**

Once authentication is verified in the Playground, the SDK can be used to perform **Passkey authentication** by communicating with the **Auth server** using the provided API key.

* The server responds with a **JWT token**, which contains **tenant metadata** to determine which tenant the user belongs to.

***

#### **Step 4: Send Requests to MPC Server**

The JWT token obtained from authentication is then used to make a **gRPC request** to the **MPC server**.

***

#### **Step 4.1: Usage Tracking Integration**

For every request sent to the **MPC server**, the usage is tracked by the **Usage Tracking service**.

* Tenant information is extracted from the JWT token using the following fields:
  * `providerTenantId`
  * `providerTenantName`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://cramiumlabs.gitbook.io/docs/feature-list/api-key.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
