---
name: "addPet"
mode: "api"
versionRequirements:
  - { name: "@ray-js/ray", version: "1.6.27" }
title: "addPet - Add pets."
---

## addPet

> [VERSION] @ray-js/ray >= 1.6.27

### Description

Add a pet

### Parameters

`Params`

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `data` | `PetAdd` | Yes | Request parameters: basic pet info, time zone timeZone, business data type dataType, etc.; see type PetAdd for details |

### Return Value

Type: `Promise<number>`

Promise; resolves to the new pet ID (number)

### Referenced Types

##### `type` PetAdd

| Property | Type | Description |
| --- | --- | --- |
| `ownerId` | `string` | Home ID |
| `petType` | `"cat" \| "dog"` | Pet type |
| `name` | `string` | Pet name, up to 40 characters |
| `avatar` | `string` | Pet avatar path, starts with "smart/" |
| `sex` | `number` | Gender: 0 - female, 1 - male, 2 - spayed female, 3 - neutered male |
| `activeness` | `number` | Activity level: 0 - inactive, 1 - normal, 2 - very active |
| `birth` | `number` | Birthday, unit: milliseconds |
| `weight` | `number` | Weight, unit: g |
| `breedCode` | `string` | Breed code (obtain from the pet breed list API) |
| `rfid` | `string` | rfid |
| `bizType` | `1 \| 2` | Business type: 1 - Pet Center, 2 - Pet Assistant, default 2 |
| `devIds` | `string[]` | Associated device IDs |
| `foodId` | `number` | Associated main food ID |
| `extInfo` | `string` | Extra information; do not include sensitive information |
| `idPhotos` | `IdPhotos[]` | Front-facing photo of the pet |
| `features` | `Feature[]` | Pet feature code |
| `personalities` | `string[]` | Pet personality code |
| `timeZone` | `string` | Time zone |
| `dataType` | `string` | Business data type |

##### `type` IdPhotos

| Property | Type | Description |
| --- | --- | --- |
| `angle` | `string` |  |
| `objectKey` | `string` |  |
| `display` | `string` |  |

##### `type` Feature

| Property | Type | Description |
| --- | --- | --- |
| `category` | `string` |  |
| `details` | `string[]` |  |

##### `type` Images

| Property | Type | Description |
| --- | --- | --- |
| `imageDisplayUrl` | `string` |  |
| `objectKey` | `string` |  |
| `angle` | `string` |  |
| `desc` | `string` |  |


### Examples

#### Request example

```typescript
import { addPet } from '@ray-js/ray';

addPet({
  bizType: 1,
  ownerId: 'xxxx',
  petType: 'cat',
  name: 'Fubao',
  avatar: 'smart/xxxx/xxxx/xxxx',
  sex: 1,
  activeness: 1,
  birth: 1614528000000,
  weight: 5000,
  breedCode: 'xxx',
  idPhotos: [
    {
      angle: 'firstFront',
      objectKey: 'xxxx',
    },
  ],
  features: [
    {
      category: 'eyeColor',
      details: ['brown'],
    },
  ],
});
```

#### Response example

```json
2
```
