> For the complete documentation index, see [llms.txt](https://docs.silicon.network/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.silicon.network/builders/opencohort/framework/developer/protocol/base-api.md).

# Base API

## API Signatures

* The authorization signature uses 'Ethereum message signing', assuming the ChainID of the relevant chain (e.g., ETH: 1, Silicon Mainnet: 2355).
* For signatures used in snapshot submissions, verification is conducted using the ETH ChainID of 1 (the ChainID is included in the message).

## Basic Response

{% code lineNumbers="true" %}

```
{
  statusCode: number;
  message: string;
  data: ResponseData;
}
```

{% endcode %}

## Success

{% code lineNumbers="true" %}

```

{
	"statusCode": 200
	"data": {},
	"message": "success"
	
}
```

{% endcode %}

## Fail

{% code lineNumbers="true" %}

```
{
	"statusCode": 500
	"message": error_message
}
```

{% endcode %}

## Error Message List

The following are basic error messages. Additional error messages may be present depending on the handling within each method.

### Basic Validation

| Message                 | Description                                                                                                                                        |
| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| invalid\_target         | When `managerName` does not match the name of the requested Manager.                                                                               |
| request\_timeout        | Request timed out.                                                                                                                                 |
| used\_signature         | When the signature value has already been processed within the allotted time (to prevent double usage).                                            |
| invalid\_cohort         | When the `CohortId` in the request does not match the `CohortId` in the requestPath, or if the `CohortId` is invalid or the cohort does not exist. |
| invalid\_owner          | When the owner in the request is missing or does not match the Owner of the `CohortId`.                                                            |
| invalid\_method         | When the method is incorrect.                                                                                                                      |
| fail\_to\_authorization | When the authorization signature verified with the hash in the body does not match the Cohort Owner.                                               |

### Basic Method Validation

| Message            | Description                                                                                                      |
| ------------------ | ---------------------------------------------------------------------------------------------------------------- |
| invalid\_members   | When the members field is missing or not in a dictionary format.                                                 |
| exceed\_limit      | When the number of members being added exceeds the limit per request.                                            |
| too\_many\_members | When the total number of members, after attempted additions, exceeds the overall limit.                          |
| invalid\_address   | When one or more addresses in the members field have an incorrect format.                                        |
| invalid\_weight    | When the format of the weight in the members field is incorrect (must be an integer between 0 and `uint32.max`). |
| pending\_snapshot  | When an `add` request is sent during the snapshot `prepare` status, but a `submit` is expected.                  |

### Signature Generation Example

#### Example 1

{% code lineNumbers="true" %}

```
dataHash = keccak256(
		abi.encode(
				[string, address, uint256, address[], address[], bytes[], uint256],
				["OpenCohort:UpdateIdentity", cohort, chainId, identityList, addressList, signatureList, validUntil]
		)
);
signingHash = ERC191(dataHash);
```

{% endcode %}

#### Example 2&#x20;

{% code lineNumbers="true" %}

```
const {
    cohort,
    chainId,
    cohortId,
    snapshotTime,
    snapshotSignature,
    validUntil
} = dto;

const dataBytes = defaultAbiCoder.encode(
    ['string', 'address', 'uint256', 'uint256', 'uint256', 'bytes', 'uint256'],
    ['OpenCohort:Submit', cohort, chainId, cohortId, snapshotTime, snapshotSignature, validUntil]
);
const dataHash = keccak256(dataBytes);
const signingBytes = Buffer.concat([
    Buffer.from('\x19Ethereum Signed Message:\n32', 'ascii'),
    Buffer.from(dataHash.replace("0x",""), 'hex')
]);
const signingHash = keccak256(signingBytes);
```

{% endcode %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.silicon.network/builders/opencohort/framework/developer/protocol/base-api.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
