The Salesforce REST API allow you to integration with Salesforce applications using standard HTTP methods such as GET, POST, PUT, PATCH, DELETE, and HEAD. This API provides a way to expose the data you have within your Salesforce application to external applications.
Follow steps to create the Apex REST API. Under App Setup expand Developer and click Apex Classes. Click New to create a new class.
Paste the following code into Apex Class Editor: