---
agentTools:
  projectIndex: https://docs.webexcampaign.com/llms.txt
---

# Create P and Ls API

This API is used to create a P and L.

> 📘 Know your endpoint
>
> Based on the domain you use to log in to Webex Campaign, the endpoint domain for your API varies. For more information, refer to the [Know Your API Endpoints](https://docs.webexcampaign.com/reference/know-your-api-endpoints) section.

## Headers

The following table describes the request headers:

[block:parameters]
{
  "data": {
    "h-0": "Request Header",
    "h-1": "Description",
    "0-0": "content-type",
    "0-1": "application/json",
    "1-0": "authorization",
    "1-1": "Access token or API Secret Key in Bearer format  \n  \nExample: `Bearer $(key)`"
  },
  "cols": 2,
  "rows": 2,
  "align": [
    "left",
    "left"
  ]
}
[/block]

## Request Parameters

| Parameter   | Type   | Mandatory |                                           |
| :---------- | :----- | :-------- | :---------------------------------------- |
| name        | String | Yes       | Specifies a name for the P and L.         |
| description | String | No        | Specifies the description for the P and L |

## Request Example

```json Create P and L

    {
        "name": "Marketing",
        "description": "Marketing P and L"
        
    }
```

## Response Parameters

This API will return the following response parameters:

| Parameter | Description                       |
| :-------- | :-------------------------------- |
| name      | Returns the name of the P and L.  |
| id        | Returns the id of the P and L.    |
| message   | Returns the confirmation message. |

## Response Example

```json Response
{
    "id": "588",
    "name": "Marketing",
    "message": "P&L created successfully"
}
```

## Failure Response Codes

The API will return code within the response as per the following table in case of failure scenarios.

| HTTP Status Code | Code within API Response | Description                                                                              |
| :--------------- | :----------------------- | :--------------------------------------------------------------------------------------- |
| 400              | 400                      | I/O error on post request. Cannot retry due to server authentication, in streaming mode. |
| 400              | 400                      | P & L name is required                                                                   |
| 401              | 430                      | Authorization failed. This resource is not allowed to access using this TOKEN or KEY     |
| 401              | 498                      | Invalid token or Access token expired                                                    |
| 404              | 404                      | Not found                                                                                |
| 405              | 405                      | Method not supported                                                                     |
| 409              | 409                      | P\&L Name already exists.                                                                |
| 500              | 500                      | Internal server error                                                                    |
| 500              | 1001                     | Invalid input JSON                                                                       |

# OpenAPI definition

```json
{
  "openapi": "3.1.0",
  "info": {
    "title": "webexcampaign Endpoint",
    "version": "7.4.7"
  },
  "servers": [
    {
      "url": "https://yourdomain.webexcampaign.io/campaignapi/resources/v3"
    }
  ],
  "security": [
    {}
  ],
  "paths": {
    "/pandls": {
      "post": {
        "summary": "Create P and Ls API",
        "description": "",
        "operationId": "create-p-and-ls-api",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "name"
                ],
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "filedetails": {
                    "type": "object",
                    "required": [
                      "name",
                      "content"
                    ],
                    "properties": {
                      "name": {
                        "type": "string"
                      },
                      "content": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "examples": {
                "Create P and L": {
                  "value": {
                    "name": "Marketing",
                    "description": "Marketing P and L",
                    "fileDetails": null
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "201",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{\n    \"id\": \"586\",\n    \"name\": \"Marketing\",\n    \"message\": \"P&L created successfully\"\n}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "example": "586"
                    },
                    "name": {
                      "type": "string",
                      "example": "Marketing"
                    },
                    "message": {
                      "type": "string",
                      "example": "P&L created successfully"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "400",
            "content": {
              "application/json": {
                "examples": {
                  "Result": {
                    "value": "{}"
                  }
                },
                "schema": {
                  "type": "object",
                  "properties": {}
                }
              }
            }
          }
        },
        "deprecated": false
      }
    }
  },
  "x-readme": {
    "headers": [
      {
        "key": "authorization",
        "value": "Bearer"
      }
    ],
    "explorer-enabled": false,
    "proxy-enabled": true
  },
  "x-readme-fauxas": true,
  "_id": "6a38ceea41ff817a72970f85:6a38ceea41ff817a729710cf"
}
```