> ## Documentation Index
> Fetch the complete documentation index at: https://docs.videnly.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Make Your First API Call

> Step-by-step guide to making your first API call using the Videnly API.

## Step 6: Make Your First API Call

With your API key integrated, you are ready to make your first request to the Videnly API.

This initial call will help you verify that your integration is working correctly and allow you to start generating videos.

### Important Requirements Before Your First Call

1. **Project ID**: Ensure you have the **ID** of the project you created. This ID is essential to specify which project configuration to use for generating videos.
2. **Credits**: Confirm that your account has sufficient credits, as each video generation request will consume credits based on your plan.
3. **Optional Parameters**: You can pass additional parameters to customize the video generation request, such as `overwriteSettings` and `customPrompt`.

### How to Make Your First API Call

<CardGroup cols={2}>
  <Card title="Prepare Your Environment" icon="code">
    You can use tools like Postman, cURL, or any programming language that supports HTTP requests.
  </Card>

  <Card title="Construct Your API Request" icon="network-wired">
    Make a POST request to the Videnly API endpoint, ensuring your API key is included in the `Authorization` header.
  </Card>
</CardGroup>

### Example of a Simple API Call

Here’s an example of making your first API call to add a video generation request to the queue:

#### Example using cURL

```bash theme={null}
curl -X POST https://api.videnly.com/v1/videos/queue/add \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"projectId": "YOUR_PROJECT_ID",
"overwriteSettings": false,
"customPrompt": null
}'
```

* Replace `YOUR_API_KEY` with the actual API key from the Developers page.
* Replace `YOUR_PROJECT_ID` with the ID of the project you created.

### Understanding the Request Body

* **projectId**: The unique ID of the project you created earlier. This is required for specifying which project settings to use for video generation.
* **overwriteSettings** (optional): A flag that can be set to `true` or `false` to determine if custom project settings should override the saved ones.
* **customPrompt** (optional | required if overwriteSettings: `true`): If provided, this custom prompt will be used instead of the default project prompt.

### Code Examples in Various Languages

Use the examples below to see how you can make an API call using different programming languages:

<CodeGroup>
  ```javascript Node.js theme={null}
  const axios = require("axios")

  const url = "https://api.videnly.com/v1/videos/queue/add"
  const headers = {
     "Content-Type": "application/json",
     Authorization: "Bearer YOUR_API_KEY",
  }
  const data = {
     projectId: "YOUR_PROJECT_ID",
     overwriteSettings: false,
     customPrompt: null,
  }

  axios
     .post(url, data, { headers: headers })
     .then((response) => console.log(response.data))
     .catch((error) => console.error(error))
  ```

  ```python Python theme={null}

  import requests

  url = 'https://api.videnly.com/v1/videos/queue/add'
  headers = {
  'Content-Type': 'application/json',
  'Authorization': 'Bearer YOUR_API_KEY'
  }
  data = {
  "projectId": "YOUR_PROJECT_ID",
  "overwriteSettings": false,
  "customPrompt": null
  }

  response = requests.post(url, headers=headers, json=data)
  print(response.text)

  ```
</CodeGroup>

### Understanding the Response

A successful API call will return a JSON response with details about the queued video generation request. Here is an example of what the response might look like:

```json theme={null}
{
   "status": "success",
   "message": "Video generation request added to queue successfully",
   "newQueueItem": {
      "queueId": "xxxxxxxxxxxxxxxxxxxxxxxx",
      "projectId": "YOUR_PROJECT_ID",
      "status": "pending",
      "generationProgress": 0,
      "renderProgress": 0,
      "videoUrl": null,
      "createdAt": "2024-11-07T14:23:45.213Z"
   }
}
```

* **status**: Indicates if the request was successful.
* **newQueueItem**: Contains details about the queued item, including `queueId`, `status`, and `createdAt`.

### Verify Your API Call

1. **Check the Response**: If your request is successful, you should see a response similar to the example above, confirming your video generation request has been added to the queue.
2. **Handle Errors**: If the request fails, check the response for error messages. Common issues might include an invalid API key, missing `projectId`, or insufficient credits.

### Tips for Your First API Call

* **Ensure You Have Credits**: Each video generation request consumes credits. Confirm your account has enough credits.
* **Include the Project ID**: Always specify the `projectId` to ensure the correct settings are applied to the video generation request.
* **Use Optional Parameters as Needed**: Use `overwriteSettings` and `customPrompt` to customize your requests.
* **Use Testing Tools**: Tools like Postman or cURL can help you debug and confirm your API call works before integrating it.

### Next Steps: Monitor the Queue

Now that you've made your first API call, you can start monitoring your queued requests by using the [Queue Progress endpoint](/api-reference/queue-progress) to check the status of your video generation requests.

> **Need Help?**\
> If you encounter any issues or need further guidance, please visit our [Support Center](https://app.videnly.com/support).
