# Get Blog Post by ID

GET https://services.leadconnectorhq.com/blogs/posts/post/{postId}

The "Get Blog Post by ID" API returns a single published blog post, including its content/body, for the given location.

## Authentication

Send `Authorization: Bearer <token>` using:

- **Sub-Account token: OAuth access token or Private Integration Token.** Scopes: `blogs/posts.readonly`

## Parameters

### Header Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `Version` | string | Yes | API Version |

### Path Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `postId` | string | Yes | Identifier of the blog post to fetch |

### Query Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `locationId` | string | Yes | Sub-account (location) identifier |

## OpenAPI Specification

```json
{
  "openapi": "3.0.0",
  "info": {
    "title": "HighLevel API",
    "version": "2021-04-15"
  },
  "servers": [
    {
      "url": "https://services.leadconnectorhq.com"
    }
  ],
  "paths": {
    "/blogs/posts/post/{postId}": {
      "get": {
        "summary": "Get Blog Post by ID",
        "operationId": "getBlogPostById",
        "description": "The \"Get Blog Post by ID\" API returns a single published blog post, including its content/body, for the given location.",
        "parameters": [
          {
            "name": "postId",
            "required": true,
            "in": "path",
            "description": "Identifier of the blog post to fetch",
            "schema": {
              "example": "66c381b38be80858b9af62b6",
              "type": "string"
            }
          },
          {
            "name": "locationId",
            "required": true,
            "in": "query",
            "description": "Sub-account (location) identifier",
            "schema": {
              "example": "ve9EPM428h8vShlRW1KT",
              "type": "string"
            }
          },
          {
            "name": "Version",
            "in": "header",
            "description": "API Version",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "2021-04-15"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful response",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BlogPostByIdResponseWrapperDTO"
                }
              }
            }
          },
          "400": {
            "description": "Bad Request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestDTO"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedDTO"
                }
              }
            }
          },
          "404": {
            "description": "Not Found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundDTO"
                }
              }
            }
          },
          "422": {
            "description": "Unprocessable Entity",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnprocessableDTO"
                }
              }
            }
          }
        },
        "security": [
          {
            "Location-Access": [
              "blogs/posts.readonly"
            ]
          }
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearer": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account (OR) Private Integration Token of Sub-Account.",
        "type": "http"
      },
      "Location-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Sub-Account.",
        "type": "http"
      },
      "Agency-Access": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency (OR) Private Integration Token of Agency.",
        "type": "http"
      },
      "Agency-Access-Only": {
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "name": "Authorization",
        "in": "header",
        "description": "Use the Access Token generated with user type as Agency.",
        "type": "http"
      }
    },
    "schemas": {
      "BlogPostByIdResponseWrapperDTO": {
        "type": "object",
        "properties": {
          "blogPost": {
            "description": "Object containing the requested published blog post with its content",
            "example": {
              "_id": "66c381b38be80858b9af62b6",
              "title": "How to grow your agency",
              "rawHTML": "<p>...</p>"
            },
            "allOf": [
              {
                "type": "object",
                "properties": {
                  "categories": {
                    "example": [
                      "659ecabc4a37969a2b7cc370",
                      "6683abde331c041f32c07aee"
                    ],
                    "description": "Array of category IDs associated with the blog post",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tags": {
                    "example": [
                      "Apple",
                      "Banana"
                    ],
                    "description": "Array of tags associated with the blog post",
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "archived": {
                    "type": "boolean",
                    "example": false,
                    "description": "Indicates whether the blog post is archived"
                  },
                  "_id": {
                    "type": "string",
                    "example": "66c381b38be80858b9af62b6",
                    "description": "Unique identifier of the blog post"
                  },
                  "title": {
                    "type": "string",
                    "example": "Banana is good source of energy",
                    "description": "Title of the blog post"
                  },
                  "description": {
                    "type": "string",
                    "example": "Description",
                    "description": "Description of the blog post"
                  },
                  "imageUrl": {
                    "type": "string",
                    "example": "https://storage.googleapis.com/blog-assets/fACm0Ojm5oC70G3DcFmE/media/66b5aa3b1745b2713a8d033f.jpeg",
                    "description": "URL of the image associated with the blog post"
                  },
                  "status": {
                    "type": "string",
                    "example": "PUBLISHED",
                    "description": "Publication status of the blog post"
                  },
                  "locationId": {
                    "type": "string",
                    "example": "fACm0Ojm5oC70G3DcFmE",
                    "description": "Identifier of the location associated with the blog post"
                  },
                  "imageAltText": {
                    "type": "string",
                    "example": "alt",
                    "description": "Alternative text for the blog post image"
                  },
                  "blogId": {
                    "type": "string",
                    "example": "ZiMMOp3ZEdnsZ4qPAjW0",
                    "description": "Unique identifier of the blog"
                  },
                  "urlSlug": {
                    "type": "string",
                    "example": "banana-good-energy",
                    "description": "URL slug for the blog post"
                  },
                  "canonicalLink": {
                    "type": "string",
                    "example": "https://blog.example.com/post/test-8384",
                    "description": "Canonical link of the blog post"
                  },
                  "author": {
                    "type": "string",
                    "example": "659ec9634a3796e4e47cc360",
                    "description": "Identifier of the author of the blog post"
                  },
                  "publishedAt": {
                    "type": "string",
                    "example": "2024-08-19T17:14:57.000Z",
                    "description": "Timestamp when the blog post was published"
                  },
                  "createdAt": {
                    "type": "string",
                    "example": "2024-08-19T17:32:35.362Z",
                    "description": "Timestamp when the blog post was created"
                  },
                  "updatedAt": {
                    "type": "string",
                    "example": "2024-08-19T17:32:36.182Z",
                    "description": "Timestamp when the blog post was last updated"
                  },
                  "currentVersion": {
                    "type": "string",
                    "example": "66c381b38be80858b9af62b7",
                    "description": "Identifier of the current version of the blog post"
                  },
                  "isAiGenerated": {
                    "type": "boolean",
                    "example": false,
                    "description": "Indicates whether the blog post was generated using AI assistance"
                  },
                  "isAIGenerated": {
                    "type": "boolean",
                    "example": false,
                    "description": "Deprecated. Use `isAiGenerated` instead. Kept for backwards compatibility.",
                    "deprecated": true
                  },
                  "rawHTML": {
                    "type": "string",
                    "description": "Full rendered HTML body of the blog post",
                    "example": "<p>Banana is a good source of energy...</p>"
                  },
                  "readTimeInMinutes": {
                    "type": "number",
                    "description": "Estimated read time of the blog post in minutes",
                    "example": 3
                  },
                  "wordCount": {
                    "type": "number",
                    "description": "Word count of the blog post body",
                    "example": 540
                  },
                  "externalFonts": {
                    "description": "External fonts referenced by the blog post body",
                    "example": [
                      "Inter",
                      "Merriweather"
                    ],
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "tocStyle": {
                    "type": "string",
                    "description": "Table-of-contents style preference for the post",
                    "example": "sidebar"
                  }
                },
                "required": [
                  "categories",
                  "tags",
                  "archived",
                  "_id",
                  "title",
                  "description",
                  "imageUrl",
                  "status",
                  "locationId",
                  "imageAltText",
                  "blogId",
                  "urlSlug",
                  "canonicalLink",
                  "author",
                  "publishedAt",
                  "createdAt",
                  "updatedAt",
                  "currentVersion",
                  "isAiGenerated",
                  "isAIGenerated",
                  "rawHTML",
                  "readTimeInMinutes",
                  "wordCount"
                ],
                "title": "BlogPostByIdContentResponseDTO"
              }
            ]
          }
        },
        "required": [
          "blogPost"
        ],
        "title": "BlogPostByIdResponseWrapperDTO"
      },
      "BadRequestDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 400
          },
          "message": {
            "type": "string",
            "example": "Bad Request"
          }
        },
        "title": "BadRequestDTO"
      },
      "UnauthorizedDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 401
          },
          "message": {
            "type": "string",
            "example": "Invalid token: access token is invalid"
          },
          "error": {
            "type": "string",
            "example": "Unauthorized"
          }
        },
        "title": "UnauthorizedDTO"
      },
      "NotFoundDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "description": "HTTP status code for not found",
            "example": 404
          },
          "message": {
            "type": "string",
            "description": "Error message describing the not found failure",
            "example": "Not Found"
          },
          "error": {
            "type": "string",
            "description": "Error type identifier",
            "example": "The requested resource was not found"
          }
        },
        "title": "NotFoundDTO"
      },
      "UnprocessableDTO": {
        "type": "object",
        "properties": {
          "statusCode": {
            "type": "number",
            "example": 422
          },
          "message": {
            "example": [
              "Unprocessable Entity"
            ],
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "error": {
            "type": "string",
            "example": "Unprocessable Entity"
          }
        },
        "title": "UnprocessableDTO"
      }
    }
  }
}
```

## HighLevel SDK Examples

**Node.js** (`@gohighlevel/api-client`)

```javascript
import HighLevel from '@gohighlevel/api-client';

const ghl = new HighLevel({
  privateIntegrationToken: '<PRIVATE_INTEGRATION_TOKEN>'
});

const response = await ghl.blogs.getBlogPostById('<POSTID>', { locationId: '<LOCATIONID>' });
console.log(response);
```

**Python** (`gohighlevel-api-client`)

```python
from highlevel import HighLevel

client = HighLevel(
    private_integration_token='<PRIVATE_INTEGRATION_TOKEN>'
)

response = await client.blogs.get_blog_post_by_id('<POSTID>', locationId='<LOCATIONID>')
print(response)
```

**PHP** (`gohighlevel/api-client`)

```php
<?php
require_once 'vendor/autoload.php';

use HighLevel\HighLevel;
use HighLevel\HighLevelConfig;

$config = new HighLevelConfig([
    'privateIntegrationToken' => '<PRIVATE_INTEGRATION_TOKEN>'
]);
$ghl = new HighLevel($config);

$response = $ghl->blogs->getBlogPostById('<POSTID>', ['locationId' => '<LOCATIONID>']);
echo json_encode($response, JSON_PRETTY_PRINT);
```

## Code Examples

**cURL**

```bash
curl -L -X GET 'https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>' \
  -H 'Authorization: Bearer <TOKEN>' \
  -H 'Version: 2021-04-15'
```

**Node.js**

```javascript
const options = {
  method: 'GET',
  headers: {
    Authorization: 'Bearer <TOKEN>',
    Version: '2021-04-15'
  }
};

try {
  const response = await fetch('https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>', options);
  const data = await response.json();
  console.log(data);
} catch (error) {
  console.error(error);
}
```

**Python**

```python
import requests

url = "https://services.leadconnectorhq.com/blogs/posts/post/{postId}"

headers = {
    "Authorization": "Bearer <TOKEN>",
    "Version": "2021-04-15"
}

params = {
    "locationId": "<LOCATIONID>"
}

response = requests.get(url, params=params, headers=headers)
print(response.json())
```

**PHP**

```php
<?php
$curl = curl_init();

curl_setopt_array($curl, [
  CURLOPT_URL => 'https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_CUSTOMREQUEST => 'GET',
  CURLOPT_HTTPHEADER => [
    'Authorization: Bearer <TOKEN>',
    'Version: 2021-04-15',
  ],
]);

$response = curl_exec($curl);
curl_close($curl);
echo $response;
```

**Java**

```java
HttpResponse<String> response = Unirest
  .get("https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>")
  .header("Authorization", "Bearer <TOKEN>")
  .header("Version", "2021-04-15")
  .asString();
```

**Go**

```go
package main

import (
  "fmt"
  "net/http"
  "io"
)

func main() {
  url := "https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>"
  req, _ := http.NewRequest("GET", url, nil)
  req.Header.Add("Authorization", "Bearer <TOKEN>")
  req.Header.Add("Version", "2021-04-15")

  res, _ := http.DefaultClient.Do(req)
  defer res.Body.Close()
  body, _ := io.ReadAll(res.Body)
  fmt.Println(string(body))
}
```

**Ruby**

```ruby
require 'uri'
require 'net/http'

url = URI("https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Get.new(url)
request["Authorization"] = "Bearer <TOKEN>"
request["Version"] = "2021-04-15"

response = http.request(request)
puts response.read_body
```

**PowerShell**

```powershell
$headers = @{
  "Authorization" = "Bearer <TOKEN>"
  "Version" = "2021-04-15"
}

$response = Invoke-RestMethod -Uri 'https://services.leadconnectorhq.com/blogs/posts/post/<postId>?locationId=<LOCATIONID>' -Method 'GET' -Headers $headers
$response | ConvertTo-Json
```
