---
title: "companyAssignCustomerAsContact"
description: "指定用户成为公司联系人"
doc_type: graphql
doc_category: adminGraphQL
doc_version: v20270301
source_url:
  html: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/mutations/company-assign-customer-as-contact'
  md: 'https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/mutations/company-assign-customer-as-contact.md'
---
# companyAssignCustomerAsContact

指定用户成为公司联系人

- **Required Scopes:** `write_customers`
- **API Version:** v20270301
- **API Type:** Admin
- **API Protocol:** GraphQL
- **Operation Type:** Mutation

## Required Permissions

* `write_customers`

接口访问需要令牌，具体如何获取令牌参考：[身份认证](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md)。

## Arguments

* `companyId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  公司id

* `customerId`

  [ID!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/common/scalars/id.md)

  客户id

## Returns

* `userErrors`

  [[BusinessCustomerUserError!]!](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/customers/objects/business-customer-user-error.md)

  错误信息

* `companyContact`

  [CompanyContact](https://developer.shopline.com/zh-hans-cn/docs/admin-graph-ql-api/b-2-b/objects/company-contact.md)

  公司联系人

## Examples

### 指定用户成为公司联系人

指定一个已存在的用户成为公司联系人

**Request:**

```json
{
  "companyId": "gid://shopline/Company/6254924101557166237",
  "customerId": "gid://shopline/Customer/4217281771"
}

```

**Response:**

```json
{
  "data": {
    "data": {
      "companyAssignCustomerAsContact": {
        "companyContact": {
          "updatedAt": "2023-11-07T10:13:38.610Z",
          "company": {
            "id": "gid://shopline/Company/6254924101557166237",
            "name": "test2"
          },
          "createdAt": "2023-11-07T10:13:38.117Z",
          "customer": {
            "lastName": "T*****",
            "phone": null,
            "addresses": [],
            "email": "********@example.com",
            "firstName": "S*****",
            "id": "gid://shopline/Customer/4217281771"
          },
          "id": "gid://shopline/CompanyContact/4217281771",
          "isMainContact": false
        },
        "userErrors": []
      }
    }
  }
}
```

## Error Handling

关于更多通用错误码说明，参考：[状态码和错误码](https://developer.shopline.com/zh-hans-cn/docs/apps/api-instructions-for-use/graph-ql-admin-api/overview.md#status-and-error-codes)。

