How to create a project using the API

With the API, you can programatically create, read, update, and delete resources such as projects, tasks, and time entries through API requests. In this article, we'll walk you through creating a project based on a template using the eHour API.

Prerequisites

Before you can create a project using the eHour API, you need an API key. Read the article "Getting Started with the API" for more information about authorization.

Steps to Create a Project

To create a project using the eHour API, follow these steps:

  1. Open your preferred API client, such as Postman or Swagger.
  2. Determine the client ID of the client you want to create the project for. To do this, you can make a GET request to the https://ehourapp.com/api/v1/clients endpoint. This will return a list of all clients associated with your eHour instance, including their ID, name, and other properties. 
  3. Next, retrieve the template ids of the templates that you want to base the project on. Make a GET request to https://ehourapp.com/api/v1/projects/templates to get all the templates and their templateId.
  4. Create the JSON for your project. Replace the clientId with the ID you retrieved in step 3 and the template ID with the ID's from the previous step.
    {
      "code": "VAC",
      "name": "Project Analysis",
      "clientId": "{clientId}",
      "templateIds": [
        "{templateId}"
      ]
    }
    		
  5. Make a PUT request to https://ehourapp.com/api/v1/projects with the JSON as the request body. (Yes, in eHour we use PUT requests for creating objects and POST for updating).
  6. Send the API request.

That's it! You've successfully created a project using the eHour API.

Response

If the project creation is successful, the API will respond with a 201 Created status code and a JSON object representing the newly created project, including its ID, URL, name, code, and other properties.

If the project creation fails, the API will respond with an appropriate error status code and a JSON object describing the error.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.

Still need help? Contact Us Contact Us