> For the complete documentation index, see [llms.txt](https://docs.console.zenlayer.com/api-reference/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.console.zenlayer.com/api-reference/zec/vnic/createnetworkinterfacepermission.md).

# CreateNetworkInterfacePermission

## 1. API Description

This API (CreateNetworkInterfacePermission) is used to grant another account permission to attach a vNIC to its own instance.

{% hint style="info" %}
**Notes**

* After the permission is granted, the grantee account can call [AttachNetworkInterface](https://docs.console.zenlayer.com/api-reference/zec/vnic/attachnetworkinterface.md) to attach the vNIC to its own instance; the vNIC still belongs to the current account.
* The permission only allows attachment and does not attach the vNIC immediately. To revoke the permission, call [DeleteNetworkInterfacePermission](https://docs.console.zenlayer.com/api-reference/zec/vnic/deletenetworkinterfacepermission.md).
  {% endhint %}

## 2. Input Parameters

The following request parameter list only provides API request parameters.

| Parameter Name | Required | Type                                                                                                | Description                                                                                                                                                                                                                                                                                          |
| -------------- | -------- | --------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| nicId          | Yes      | String                                                                                              | <p>ID of the vNIC to be granted.</p><p>It can be obtained by calling <a href="https://docs.console.zenlayer.com/api-reference/zec/vnic/describenetworkinterfaces.md">DescribeNetworkInterfaces</a>.</p><p>The primary vNIC is not supported, and the vNIC status must be <code>AVAILABLE</code>.</p> |
| granteeCid     | Yes      | String                                                                                              | <p>CID of the grantee account. It cannot be the account that owns the vNIC.</p><p>A vNIC can be granted to only one account. If the same operation is granted to the same account again, the existing permission is returned.</p>                                                                    |
| permission     | Yes      | [NicPermission](https://docs.console.zenlayer.com/api-reference/zec/datastructure.md#nicpermission) | Operation to be granted.                                                                                                                                                                                                                                                                             |

## 3. Output Parameters

| Parameter Name | Type   | Description                                                                                                           |
| -------------- | ------ | --------------------------------------------------------------------------------------------------------------------- |
| requestId      | String | <p>The unique request ID, which is returned for each request.</p><p>RequestId is required for locating a problem.</p> |
| permissionId   | String | vNIC permission ID.                                                                                                   |

## 4. Code Example

{% tabs %}
{% tab title="Example" %}
**1. Grant another account permission to attach a vNIC.**

```json
POST /api/v2/zec HTTP/1.1
Host: console.zenlayer.com
Content-Type: application/json
X-ZC-Action: CreateNetworkInterfacePermission
<Common Request Params>

Request:
{
  "nicId": "<nicId>",
  "granteeCid": "<granteeCid>",
  "permission": "INSTANCE_ATTACH"
}

Response:
{
  "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
  "response": {
    "requestId": "T05992D0C-7E8B-4047-B0C0-780F2CD549D3",
    "permissionId": "<permissionId>"
  }
}
```

{% endtab %}
{% endtabs %}

## 5. Developer Resources

Zenlayer Cloud API 2.0 integrates [SDKs](https://docs.console.zenlayer.com/api-reference/api-introduction/toolkit/api-sdk.md)，to make it easier for you to call APIs. More programming languages will be supported.

## 6. Error Codes

The following only lists the error codes related to the API business logic. For other error codes, see [Common Error Codes](https://docs.console.zenlayer.com/api-reference/api-introduction/instruction/commonerrorcode.md).

| HTTP Status Code | Error Code                                    | Description                                                                                    |
| ---------------- | --------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| 404              | INVALID\_NIC\_NOT\_FOUND                      | vNIC does not exist.                                                                           |
| 400              | INVALID\_NIC\_STATUS                          | Current vNIC state does not allow this operation.                                              |
| 404              | INVALID\_NIC\_PERMISSION\_GRANTEE\_NOT\_FOUND | The grantee account does not exist.                                                            |
| 400              | INVALID\_NIC\_PERMISSION\_GRANTEE\_SELF       | A vNIC cannot be granted to the account that owns it.                                          |
| 400              | OPERATION\_DENIED\_NIC\_PERMISSION\_EXISTS    | A vNIC can be granted to only one account, and it has already been granted to another account. |
| 400              | UNSUPPORTED\_OPERATION\_NIC\_IS\_PRIMARY      | This operation is not supported on the primary vNIC.                                           |
