# Update An Entity

## Updating an Entity

<mark style="color:orange;">`PUT`</mark> `/api/v1/{entity-type}/{id}`

#### Path Parameters

| Name                                          | Type   | Description                  |
| --------------------------------------------- | ------ | ---------------------------- |
| entity-type<mark style="color:red;">\*</mark> | String | The type of entity to modify |
| id<mark style="color:red;">\*</mark>          | String | The ID of entity to modify   |

#### Headers

| Name                                           | Type   | Description                                                                               |
| ---------------------------------------------- | ------ | ----------------------------------------------------------------------------------------- |
| authorization                                  | String | Set to Bearer {access-token} if roles in schema is not anonymous. Else token can be empty |
| content-type<mark style="color:red;">\*</mark> | String | Set to `application/json`                                                                 |

#### Request Body

| Name                                  | Type   | Description       |
| ------------------------------------- | ------ | ----------------- |
| ...<mark style="color:red;">\*</mark> | String | The entity's data |

{% tabs %}
{% tab title="200: OK Updated Entity Success Response" %}

```javascript
{
	"id": "sunbird-rc.registry.update",
	"ver": "1.0",
	"ets": 1634371946769,
	"params": {
		"resmsgid": "",
		"msgid": "d51e6e6a-027d-4a42-84bb-2ce00e31d993",
		"err": "",
		"status": "SUCCESSFUL",
		"errmsg": ""
	},
	"responseCode": "OK"
}
```

{% endtab %}
{% endtabs %}

## Usage

### cURL

```
curl --location \
	--request 'PUT' \
	--header 'content-type: application/json' \
	--header 'authorization: bearer {access-token}' \
	--data-raw '{
		"phoneNumber": "1234567891",
		"school": "UP Public School",
		"subject": "Math",
		"name": "Pranav Agate",
	}' \
	'{registry-url}/api/v1/{entity-type}/{id}'
```

### HTTPie

```
printf '{
	"phoneNumber": "1234567891",
	"school": "UP Public School",
	"subject": "Math",
	"name": "Pranav Agate",
}' | http put \
	'{registry-url}/api/v1/{entity-type}/{id}' \
	'content-type: application/json' \
	'authorization: bearer {access-token}'
```

> `{registry-url}` is usually [http://localhost:{port}](https://rc.sunbird.org/v1.0.0/api-reference/registry/http:/localhost:{port}). The port can be found under the `registry` section in the `docker-compose.yml` file and is usually `8081`.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://rc.sunbird.org/v1.0.0/api-reference/registry/update-an-entity.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
