# How to update identity?

### Arrange Identity

Arrange identity in the format

* If want to remove addresses from secondary, do not add them in the list
* If want to add new addresses in secondary, add them in secondary list
* If want to keep some addresses in secondary, then keep them in the data

```json
{
  "id": "string",
  "identifier": "string",
  "provider": "string",
  "default": {
    "address": "address",
    "chain": number,
    "isContract": boolean
  },
  "secondary": [
    {
      "address": "address",
      "chain": number,
      "isContract": boolean
    },
    {
      "address": "address",
      "chain": number,
      "isContract": boolean
    }
  ]
}

```

### Generate Message

Using the above arranged identity, generate a message using the below endpoint and sign it using `default` address by following [guide for respective chains](https://docs.fetcch.xyz/how-to-integrate/guides/utility)

{% openapi src="<https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5>" path="/identity/generate-message" method="post" %}
[openapi.yml](https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media\&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5)
{% endopenapi %}

After generating message, you need to sign `message` using appropriate functions for respective chains, check our guide for each blockchain [here](https://docs.fetcch.xyz/how-to-integrate/guides/utility)

There are 2 signatures needed while updating identity

* `currentSignature` - Will be signed by current (new) `default` address
* `previousSignature` - Will be signed by previous (old) `default` address, only if `default` is updated
* If `default` isn't updated, you need to use same signature for both `currentSignature` and `previousSignature`

### Update Identity

After signing the message, add the generated signature in the [arranged identity](#arrange-identity), at `currentSignature` and `previousSignature` respectively

Now, data should look something like this

```json
{
  "id": "string",
  "identifier": "string",
  "provider": "string",
  "default": {
    "address": "address",
    "chain": number,
    "isMultisig": boolean,
    "isSmartContractWallet": boolean
  },
  "secondary": [
    {
      "address": "address",
      "chain": number,
      "isMultisig": boolean,
      "isSmartContractWallet": boolean
    },
    {
      "address": "address",
      "chain": number,
      "isMultisig": boolean,
      "isSmartContractWallet": boolean
    }
  ],
  "currentSignature": "string",
  "previousSignature": "string"
}
```

Call **Update Identity** API

#### Important Note

* If `default` chain is `APTOS`, then while calling this API, swap `default` address with public key of the same address, so that we can easily verify signatures
* If `default` is changing in this request, then send previous `default` address's public key in `extraData: { publicKey: "" }`
* For example
  * `satyam@martian` has `APTOS` has default chain
  * In this request, we are updating it to `EVM`
  * Signed message using `EVM` address will be in `currentSignature`
  * Signed message using `APTOS` address will be in `previousSignature`
  * To verify `previousSignature`, we need to have `publicKey` of the `APTOS` address, which we will send in `extraData`

So now, data will look something like this

```json
{
  "id": "string",
  "identifier": "string",
  "provider": "string",
  "default": {
    "address": "address",
    "chain": number,
    "isMultisig": boolean,
    "isSmartContractWallet": boolean
  },
  "secondary": [
    {
      "address": "address",
      "chain": number,
      "isMultisig": boolean,
      "isSmartContractWallet": boolean
    },
    {
      "address": "address",
      "chain": number,
      "isMultisig": boolean,
      "isSmartContractWallet": boolean
    }
  ],
  "currentSignature": "string",
  "previousSignature": "string",
  "extraData": {
    "publicKey": "string"
  }
}
```

{% openapi src="<https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5>" path="/identity" method="patch" %}
[openapi.yml](https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media\&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5)
{% endopenapi %}

Identity should now be created, if faced with any error, check our [troubleshooting guide](https://docs.fetcch.xyz/how-to-integrate/api-reference/troubleshooting-errors) or ask in our discord

### Resolve Identity

{% openapi src="<https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5>" path="/identity" method="get" %}
[openapi.yml](https://2219691098-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FxaHazojZlIts4pidXQC6%2Fuploads%2FfnFyuZwzFVn93GBdO4kv%2Fopenapi.yml?alt=media\&token=7e1414fc-c6b1-4244-9549-9bb061a79cc5)
{% endopenapi %}
