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

# Update Blog Post

> The "Update Blog Post" API allows you update blog post for any given blog site. Please use blogs/post-update.write

The "Update Blog Post" API allows you update blog post for any given blog site. Please use blogs/post-update.write

```http theme={null}
PUT https://services.leadconnectorhq.com/blogs/posts/{postId}
```

## Autorización

<ParamField header="Authorization" type="string" required>
  Bearer token generado desde el portal Leadway. Ver [Autenticación](/authentication).
</ParamField>

<ParamField header="Version" type="string" required default="2021-07-28">
  Versión de la API.
</ParamField>

## Body

<ParamField body="title" type="string" required default="Your blog title" />

<ParamField body="locationId" type="string" required default="Account ID" />

<ParamField body="blogId" type="string" required default="Blog ID">
  You can find the blog id from blog site dashboard link
</ParamField>

<ParamField body="imageUrl" type="string" required default="Image URl" />

<ParamField body="description" type="string" required default="A short description" />

<ParamField body="rawHTML" type="string" required default="<h1>Your blog content</h1>" />

<ParamField body="status" type="string" required default="PUBLISHED">
  Posibles valores: 'DRAFT', 'PUBLISHED', 'SCHEDULED', 'ARCHIVED'
</ParamField>

<ParamField body="imageAltText" type="string" required default="Alt text for your blog image" />

<ParamField body="categories" type="string[]" required>
  This needs to be array of category ids, which you can get from the category get api call.
</ParamField>

<ParamField body="tags" type="string[]" />

<ParamField body="author" type="string" required default="6683abde331c041f32c07aea">
  This needs to be author id, which you can get from the author get api call.
</ParamField>

<ParamField body="urlSlug" type="string" required default="any-blog-post-url" />

<ParamField body="canonicalLink" type="string" default="https://tryghl.blog/post/testing-unsplash" />

<ParamField body="publishedAt" type="string" required default="2025-02-05T18:30:47.000Z">
  Provide ISO timestamp
</ParamField>

## Respuestas

<Accordion title="200 - Successful response">
  <ResponseField name="updatedBlogPost" type="object" required>
    <Expandable title="propiedades">
      <ResponseField name="categories" type="string[]" required>
        Array of category IDs associated with the blog post
      </ResponseField>

      <ResponseField name="tags" type="string[]">
        Array of tags associated with the blog post
      </ResponseField>

      <ResponseField name="archived" type="boolean" required default="False">
        Indicates whether the blog post is archived
      </ResponseField>

      <ResponseField name="_id" type="string" required default="66c381b38be80858b9af62b6">
        Unique identifier of the blog post
      </ResponseField>

      <ResponseField name="title" type="string" required default="Banana is good source of energy">
        Title of the blog post
      </ResponseField>

      <ResponseField name="description" type="string" required default="Description">
        Description of the blog post
      </ResponseField>

      <ResponseField name="imageUrl" type="string" required default="https://storage.googleapis.com/ghl-test/fACm0Ojm5oC70G3DcFmE/media/66b5aa3b1745b2713a8d033f.jpeg">
        URL of the image associated with the blog post
      </ResponseField>

      <ResponseField name="status" type="string" required default="PUBLISHED">
        Publication status of the blog post
      </ResponseField>

      <ResponseField name="imageAltText" type="string" required default="alt">
        Alternative text for the blog post image
      </ResponseField>

      <ResponseField name="urlSlug" type="string" required default="banana-good-energy">
        URL slug for the blog post
      </ResponseField>

      <ResponseField name="canonicalLink" type="string" default="https://blog.chatgpts.agency/post/test-8384">
        Canonical link of the blog post
      </ResponseField>

      <ResponseField name="author" type="string" default="659ec9634a3796e4e47cc360">
        Identifier of the author of the blog post
      </ResponseField>

      <ResponseField name="publishedAt" type="string" required default="2024-08-19T17:14:57.000Z">
        Timestamp when the blog post was published
      </ResponseField>

      <ResponseField name="updatedAt" type="string" required default="2024-08-19T17:32:36.182Z">
        Timestamp when the blog post was last updated
      </ResponseField>
    </Expandable>
  </ResponseField>

  ```json theme={null}
  {
    "updatedBlogPost": {
      "categories": [
        "659ecabc4a37969a2b7cc370",
        "6683abde331c041f32c07aee"
      ],
      "tags": [
        "Apple",
        "Banana"
      ],
      "archived": false,
      "_id": "66c381b38be80858b9af62b6",
      "title": "Banana is good source of energy",
      "description": "Description",
      "imageUrl": "https://storage.googleapis.com/ghl-test/fACm0Ojm5oC70G3DcFmE/media/66b5aa3b1745b2713a8d033f.jpeg",
      "status": "PUBLISHED",
      "imageAltText": "alt",
      "urlSlug": "banana-good-energy",
      "canonicalLink": "https://blog.chatgpts.agency/post/test-8384",
      "author": "659ec9634a3796e4e47cc360",
      "publishedAt": "2024-08-19T17:14:57.000Z",
      "updatedAt": "2024-08-19T17:32:36.182Z"
    }
  }
  ```
</Accordion>

<Accordion title="400 - Bad Request">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="401 - Unauthorized">
  ```json theme={null}
  {}
  ```
</Accordion>

<Accordion title="422 - Unprocessable Entity">
  ```json theme={null}
  {}
  ```
</Accordion>

## Ejemplo

<CodeGroup>
  ```bash cURL theme={null}
  curl -X PUT 'https://services.leadconnectorhq.com/blogs/posts/YOUR_postId' \
    -H 'Authorization: Bearer YOUR_TOKEN' \
    -H 'Version: 2021-07-28' \
    -H 'Content-Type: application/json' \
    -d '{
    "title": "Your blog title",
    "locationId": "Account ID",
    "blogId": "Blog ID",
    "imageUrl": "Image URl",
    "description": "A short description",
    "rawHTML": "<h1>Your blog content</h1>",
    "status": "PUBLISHED",
    "imageAltText": "Alt text for your blog image",
    "categories": [
      "9c48df2694a849b6089f9d0d3513efe",
      "6683abde331c041f32c07aee"
    ],
    "tags": [
      "blog",
      "seo"
    ],
    "author": "6683abde331c041f32c07aea",
    "urlSlug": "any-blog-post-url",
    "canonicalLink": "https://tryghl.blog/post/testing-unsplash",
    "publishedAt": "2025-02-05T18:30:47.000Z"
  }'
  ```

  ```javascript Node.js theme={null}
  const response = await fetch('https://services.leadconnectorhq.com/blogs/posts/YOUR_postId', {
    method: 'PUT',
    headers: {
      Authorization: `Bearer ${process.env.LEADWAY_TOKEN}`,
      Version: '2021-07-28',
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({"title": "Your blog title", "locationId": "Account ID", "blogId": "Blog ID", "imageUrl": "Image URl", "description": "A short description", "rawHTML": "<h1>Your blog content</h1>", "status": "PUBLISHED", "imageAltText": "Alt text for your blog image", "categories": ["9c48df2694a849b6089f9d0d3513efe", "6683abde331c041f32c07aee"], "tags": ["blog", "seo"], "author": "6683abde331c041f32c07aea", "urlSlug": "any-blog-post-url", "canonicalLink": "https://tryghl.blog/post/testing-unsplash", "publishedAt": "2025-02-05T18:30:47.000Z"}),
  });
  const data = await response.json();
  ```

  ```python Python theme={null}
  import os, requests
  response = requests.request(
      'PUT',
      'https://services.leadconnectorhq.com/blogs/posts/YOUR_postId',
      headers={
          'Authorization': f"Bearer {os.environ['LEADWAY_TOKEN']}",
          'Version': '2021-07-28',
          'Content-Type': 'application/json',
      },
      json={"title": "Your blog title", "locationId": "Account ID", "blogId": "Blog ID", "imageUrl": "Image URl", "description": "A short description", "rawHTML": "<h1>Your blog content</h1>", "status": "PUBLISHED", "imageAltText": "Alt text for your blog image", "categories": ["9c48df2694a849b6089f9d0d3513efe", "6683abde331c041f32c07aee"], "tags": ["blog", "seo"], "author": "6683abde331c041f32c07aea", "urlSlug": "any-blog-post-url", "canonicalLink": "https://tryghl.blog/post/testing-unsplash", "publishedAt": "2025-02-05T18:30:47.000Z"},
  )
  data = response.json()
  ```

  ```php PHP theme={null}
  <?php
  $ch = curl_init('https://services.leadconnectorhq.com/blogs/posts/YOUR_postId');
  curl_setopt_array($ch, [
      CURLOPT_RETURNTRANSFER => true,
      CURLOPT_CUSTOMREQUEST => 'PUT',
      CURLOPT_HTTPHEADER => [
          'Authorization: Bearer ' . getenv('LEADWAY_TOKEN'),
          'Version: 2021-07-28',
          'Content-Type: application/json',
      ],
      CURLOPT_POSTFIELDS => json_encode({'title': 'Your blog title', 'locationId': 'Account ID', 'blogId': 'Blog ID', 'imageUrl': 'Image URl', 'description': 'A short description', 'rawHTML': '<h1>Your blog content</h1>', 'status': 'PUBLISHED', 'imageAltText': 'Alt text for your blog image', 'categories': ['9c48df2694a849b6089f9d0d3513efe', '6683abde331c041f32c07aee'], 'tags': ['blog', 'seo'], 'author': '6683abde331c041f32c07aea', 'urlSlug': 'any-blog-post-url', 'canonicalLink': 'https://tryghl.blog/post/testing-unsplash', 'publishedAt': '2025-02-05T18:30:47.000Z'}),
  ]);
  $data = json_decode(curl_exec($ch), true);
  ```
</CodeGroup>
