---
description: Manage information about a particular person.
---

# Agent Profile Resource

## createAgentProfile

Creates or merges into an agent profile document by the agent and agent profile identifier.

### **Example**

```typescript
const agent: Agent = {
  objectType: "Agent",
  name: "Test Agent",
  mbox: "mailto:test@agent.com"
};
const profileId: string = "https://example.com/profiles/myProfileId";
const profile: DocumentJson = {
  myKey: "myValue"
};

xapi.createAgentProfile({
  agent: agent,
  profileId: profileId,
  profile: profile
});
```

### **Parameters**

| Parameter   | Type                                                                                                                            | Required | Description                                                  |
| ----------- | ------------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------ |
| agent       | [Agent](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/interfaces/Statement/Actor/Agent.ts)   | true     | The agent experiencing the AU.                               |
| profileId   | string                                                                                                                          | true     | The URI of the agent profile to be created or merged into.   |
| profile     | [DocumentJson](https://github.com/xapijs/xapi/blob/d7eac9d07166df5c1f995e17a8ac98bbee99c548/src/resources/document/Document.ts) | true     | The profile data to be stored.                               |
| etag        | string                                                                                                                          | false    | The ETag of the original document if merging.                |
| matchHeader | string                                                                                                                          | false    | The ETag header type. Accepts "If-Match" or "If-None-Match". |
| contentType | string                                                                                                                          | false    | The content type of the profile data.                        |

### **Returns**

This method returns an `AxiosPromise` with empty success `data` if successful.

## setAgentProfile

Creates or overwrites an agent profile document by the agent and agent profile identifier.

### **Example**

```typescript
const agent: Agent = {
  objectType: "Agent",
  name: "Test Agent",
  mbox: "mailto:test@agent.com"
};
const profileId: string = "https://example.com/profiles/myProfileId";
const profile: Document = {
  myKey: "myValue"
};

xapi.setAgentProfile({
  agent: agent,
  profileId: profileId,
  profile: profile
});
```

### **Parameters**

| Parameter   | Type                                                                                                                          | Required | Description                                                  |
| ----------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------ |
| agent       | [Agent](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/interfaces/Statement/Actor/Agent.ts) | true     | The agent experiencing the AU.                               |
| profileId   | string                                                                                                                        | true     | The URI of the agent profile to be created or overwritten.   |
| profile     | [Document](https://github.com/xapijs/xapi/blob/d7eac9d07166df5c1f995e17a8ac98bbee99c548/src/resources/document/Document.ts)   | true     | The profile data to be stored.                               |
| etag        | string                                                                                                                        | true     | The ETag of the original document if overwriting.            |
| matchHeader | string                                                                                                                        | true     | The ETag header type. Accepts "If-Match" or "If-None-Match". |

### **Returns**

This method returns an `AxiosPromise` with empty success `data` if successful.

## getAgentProfiles

Gets an array of agent profile identifiers by the agent.

### **Example**

```typescript
const agent: Agent = {
  objectType: "Agent",
  name: "Test Agent",
  mbox: "mailto:test@agent.com"
};

xapi.getAgentProfiles({
  agent: agent
}).then((result: AxiosResponse<string[]>) => {
  const profiles: string[] = result.data;
  console.log(profiles); // ["https://example.com/profiles/myProfileId"]
});
```

### **Parameters**

| Parameter      | Type                                                                                                                          | Required | Description                                                  |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------------------------------ |
| agent          | [Agent](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/interfaces/Statement/Actor/Agent.ts) | true     | The agent experiencing the AU.                               |
| since          | Timestamp                                                                                                                     | false    | Only return Agent Profiles stored since specified Timestamp. |
| useCacheBuster | boolean                                                                                                                       | false    | Enables cache busting.                                       |

### **Returns**

This method returns an `AxiosPromise` with the success `data` containing an array of agent profile identifiers if successful.

## getAgentProfile

Gets an agent profile document by the agent and the agent profile identifier.

### **Example**

```typescript
const agent: Agent = {
  objectType: "Agent",
  name: "Test Agent",
  mbox: "mailto:test@agent.com"
};
const profileId: string = "https://example.com/profiles/myProfileId";

xapi.getAgentProfile({
  agent: agent,
  profileId: profileId
}).then((result: AxiosResponse<Document>) => {
  const profile: Document = result.data;
  // do stuff with profile
});
```

### **Parameters**

| Parameter      | Type                                                                                                                          | Required | Description                             |
| -------------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | --------------------------------------- |
| agent          | [Agent](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/interfaces/Statement/Actor/Agent.ts) | true     | The agent experiencing the AU.          |
| profileId      | string                                                                                                                        | true     | The URI of the profile to be retrieved. |
| useCacheBuster | boolean                                                                                                                       | false    | Enables cache busting.                  |

### **Returns**

This method returns an `AxiosPromise` with the success `data` containing the stored [Document](https://github.com/xapijs/xapi/blob/d7eac9d07166df5c1f995e17a8ac98bbee99c548/src/resources/document/Document.ts) if successful.

## deleteAgentProfile

Deletes an agent profile document by the agent and the agent profile identifier.

### **Example**

```typescript
const agent: Agent = {
  objectType: "Agent",
  name: "Test Agent",
  mbox: "mailto:test@agent.com"
};
const profileId: string = "https://example.com/profiles/myProfileId";

xapi.deleteAgentProfile({
  agent: agent,
  profileId: profileId
});
```

### **Parameters**

| Parameter | Type                                                                                                                          | Required | Description                           |
| --------- | ----------------------------------------------------------------------------------------------------------------------------- | -------- | ------------------------------------- |
| agent     | [Agent](https://github.com/xapijs/xapi/tree/fd040c6f049f68fce317538626906de57ffebf44/src/interfaces/Statement/Actor/Agent.ts) | true     | The agent experiencing the AU.        |
| profileId | string                                                                                                                        | true     | The URI of the profile to be deleted. |
| etag      | string                                                                                                                        | false    | The ETag of the original document.    |

### **Returns**

This method returns an `AxiosPromise` with empty success `data` if successful.
