> For the complete documentation index, see [llms.txt](https://docs.digit.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digit.org/local-governance/v2.7/platform/configure-digit/configuring-digit-services/api-dos-and-donts.md).

# API Checklist

## Do's and Don'ts

* Always define the Yaml for your APIs as the first thing using Open API 3 Standard (<https://swagger.io/specification/>).
* APIs path should be standardised as follows:
  * **/{service}/{entity}/{version}/\_create**: This endpoint should be used to create the entity.
  * **/{service}/{entity}/{version}/\_update**: This endpoint should be used to edit an entity which is already existing.
  * **/{service}/{entity}/{version}/\_search**: This endpoint should be used to provide a search on the entity based on certain criteria.
  * **/{service}/{entity}/{version}/\_count**: This endpoint should be provided to give a count of entities that match the given search criteria.
* Always use POST for each of the endpoints.
* Take most search parameters in the POST body only.
* If query params for search need to be supported then make sure to have the same parameters in the POST body also and the POST body should take priority over query params.
* Provide additional detail for objects in **\_create** and **\_update** APIs so that custom requirements can use these fields.
* Each API should have a [**RequestInfo**](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L45) object in the request body at the top level.
* Each API should have a [**ResponseInfo**](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L154) object in the response body at the top level.
* Mandatory fields should be the minimum for the APIs.
* minLength and maxLength should be defined for each attribute.
* Read-only fields should be called out.
* Use common models already available in the platform in your APIs. Example -
  * [Address](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L228)
  * [User](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L96) (Citizen/ Employee/ Owner)
  * [Role](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L130)
  * [AuditDetails](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L270)
  * [ErrorRes](https://github.com/egovernments/core-services/blob/4e92620bd77fce183fdd66d3a8d9248f65561ada/docs/common-contract.yml#L213) (Response sent in case of errors)
  * TODO: Add all the models here
* For receiving files in an API, do not use binary file data. Instead, accept the file store ids.
* If there is only one file to be uploaded and no persistence is needed, and no additional JSON data is to be posted, you can consider using direct file upload instead of using filestore id.

APIs developed on DIGIT follow certain conventions and principles. The aim of this document is to provide some do’s and don’ts while following these principles.

[![Creative Commons License](https://i.creativecommons.org/l/by/4.0/80x15.png)​](http://creativecommons.org/licenses/by/4.0/)All content on this page by [eGov Foundation](https://egov.org.in/) is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.digit.org/local-governance/v2.7/platform/configure-digit/configuring-digit-services/api-dos-and-donts.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
